From 821d0806feb3648ced5809a78b07581ea3bd7880 Mon Sep 17 00:00:00 2001 From: metagn <metagngn@gmail.com> Date: Fri, 27 Sep 2024 16:34:09 +0300 Subject: Revert "make default values typed in proc AST same as param sym AST" (#24191) Reverts #24184, reopens #12942, reopens #19118 #24184 seems to have caused a regression in https://github.com/c-blake/thes and https://github.com/c-blake/bu/blob/main/rp.nim#L84 reproducible with `git clone https://github.com/c-blake/cligen; git clone https://github.com/c-blake/thes; cd thes; nim c -p=../cligen thes`. Changing the `const` to `let` makes it compile. A minimization that is probably the same issue is: ```nim const a: seq[string] = @[] proc foo(x = a) = echo typeof(x) echo x import macros macro resemFoo() = result = getImpl(bindSym"foo") block: resemFoo() # Error: cannot infer the type of parameter 'x' ``` This should be a regression test in a future reimplementation of #24184. --- tests/proc/tdefaultvalueprocast.nim | 50 ------------------------------------- 1 file changed, 50 deletions(-) delete mode 100644 tests/proc/tdefaultvalueprocast.nim (limited to 'tests/proc') diff --git a/tests/proc/tdefaultvalueprocast.nim b/tests/proc/tdefaultvalueprocast.nim deleted file mode 100644 index cc5c4df25..000000000 --- a/tests/proc/tdefaultvalueprocast.nim +++ /dev/null @@ -1,50 +0,0 @@ -discard """ - nimout: ''' -ProcDef - Sym "foo" - Empty - Empty - FormalParams - Empty - IdentDefs - Sym "x" - Empty - Call - Sym "none" - Sym "Natural" - Empty - Empty - DiscardStmt - Empty -ProcDef - Sym "example" - Empty - Empty - FormalParams - Empty - IdentDefs - Sym "a" - Empty - Sym "thing" - Empty - Empty - DiscardStmt - TupleConstr - Sym "a" - Sym "thing" -''' -""" - -import options, macros - -macro typedTree(n: typed): untyped = - result = n - echo treeRepr n - -# issue #19118 -proc foo(x = none(Natural)) {.typedTree.} = discard - -# issue #12942 -var thing = 2 -proc example(a = thing) {.typedTree.} = - discard (a, thing) -- cgit 1.4.1-2-gfad0