Skip to content

Commit

Permalink
fix renderer, add test for nim-lang#7085
Browse files Browse the repository at this point in the history
  • Loading branch information
metagn committed Jun 11, 2023
1 parent 865c7a5 commit 7f46843
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
1 change: 1 addition & 0 deletions compiler/renderer.nim
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,7 @@ proc atom(g: TSrcGen; n: PNode): string =
of nkEmpty: result = ""
of nkIdent: result = n.ident.s
of nkSym: result = n.sym.name.s
of nkClosedSymChoice, nkOpenSymChoice: result = n[0].sym.name.s
of nkStrLit: result = ""; result.addQuoted(n.strVal)
of nkRStrLit: result = "r\"" & replace(n.strVal, "\"", "\"\"") & '\"'
of nkTripleStrLit: result = "\"\"\"" & n.strVal & "\"\"\""
Expand Down
11 changes: 11 additions & 0 deletions tests/template/mdotcall.nim
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# issue #20073

type Foo = object
proc foo(f: Foo) = discard

Expand All @@ -9,3 +11,12 @@ 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
8 changes: 6 additions & 2 deletions tests/template/tdotcall.nim
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# issue #20073

import mdotcall

# issue #20073
works()
boom()

# issue #7085
doAssert baz("hello") == "hellobar"
doAssert baz"hello" == "hellobar"
doAssert "hello".baz == "hellobar"

0 comments on commit 7f46843

Please sign in to comment.