mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-22 07:15:22 +00:00
fix dot calls with resolved symbols in templates (#22076)
* fix dot calls with resolved symbols in templates * make old code work * fix custom number literals test * remove leftover debug marker * enable "bug 9" test too * fix renderer, add test for #7085
This commit is contained in:
22
tests/template/mdotcall.nim
Normal file
22
tests/template/mdotcall.nim
Normal file
@@ -0,0 +1,22 @@
|
||||
# issue #20073
|
||||
|
||||
type Foo = object
|
||||
proc foo(f: Foo) = discard
|
||||
|
||||
template works*() =
|
||||
var f: Foo
|
||||
foo(f)
|
||||
|
||||
template boom*() =
|
||||
var f: Foo
|
||||
f.foo() # Error: attempting to call undeclared routine: 'foo'
|
||||
f.foo # Error: undeclared field: 'foo' for type a.Foo
|
||||
|
||||
# issue #7085
|
||||
|
||||
proc bar(a: string): string =
|
||||
return a & "bar"
|
||||
|
||||
template baz*(a: string): string =
|
||||
var b = a.bar()
|
||||
b
|
||||
10
tests/template/tdotcall.nim
Normal file
10
tests/template/tdotcall.nim
Normal file
@@ -0,0 +1,10 @@
|
||||
import mdotcall
|
||||
|
||||
# issue #20073
|
||||
works()
|
||||
boom()
|
||||
|
||||
# issue #7085
|
||||
doAssert baz("hello") == "hellobar"
|
||||
doAssert baz"hello" == "hellobar"
|
||||
doAssert "hello".baz == "hellobar"
|
||||
Reference in New Issue
Block a user