Skip to content

options.none(T) is nnkOpenSymChoice in typed AST of proc argument #19118

Open
@alaviss

Description

@alaviss

Example

import options, macros

macro typedTree(n: typed): untyped =
  result = n
  echo treeRepr n

proc foo(x = none(Natural)) {.typedTree.} = discard

Current Output

ProcDef
  Sym "foo"
  Empty
  Empty
  FormalParams
    Empty
    IdentDefs
      Sym "x"
      Empty
      Call
        OpenSymChoice 2 "none"
        Sym "Natural"
  Empty
  Empty
  DiscardStmt
    Empty

Expected Output

ProcDef
  Sym "foo"
  Empty
  Empty
  FormalParams
    Empty
    IdentDefs
      Sym "x"
      Empty
      Call
        Sym "none"
        Sym "Natural"
  Empty
  Empty
  DiscardStmt
    Empty

Additional Information

  • CPS relies on the value to have a type to infer the parameter type. However that is not the case here where somehow none was an OpenSymChoice, which should be impossible in typed AST.
$ nim -v
Nim Compiler Version 1.7.1 [Linux: amd64]
Compiled at 2021-11-08
Copyright (c) 2006-2021 by Andreas Rumpf

git hash: 83a9c3ba31d180cd5e31026d8b7603bf7adea18c
active boot switches: -d:release -d:nimUseLinenoise

Metadata

Metadata

Assignees

No one assigned

    Labels

    CPSbugs/pulls related to the cps projectMacros

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions