Skip to content

Commit

Permalink
One more fix. Fixes nim-lang#7363
Browse files Browse the repository at this point in the history
  • Loading branch information
cooldome committed Mar 23, 2018
1 parent e2c2ae8 commit 8935dde
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
3 changes: 3 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
the use of `static[T]` types.
(#6415)

- The `emit` pragma now supports backticking of Nim expressions, previously
only symbols were supports, example

### Tool changes

- ``jsondoc2`` has been renamed ``jsondoc``, similar to how ``doc2`` was renamed
Expand Down
5 changes: 3 additions & 2 deletions compiler/pragmas.nim
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import
os, platform, condsyms, ast, astalgo, idents, semdata, msgs, renderer,
wordrecg, ropes, options, strutils, extccomp, math, magicsys, trees,
rodread, types, lookups
rodread, types, lookups, parser

const
FirstCallConv* = wNimcall
Expand Down Expand Up @@ -483,7 +483,8 @@ proc semAsmOrEmit*(con: PContext, n: PNode, marker: char): PNode =
incl(e.flags, sfUsed)
addSon(result, newSymNode(e))
else:
addSon(result, newStrNode(nkStrLit, sub))
let n2 = parseString(sub, con.cache, con.filename)
addSon(result, con.semExpr(con, n2))
else:
# an empty '``' produces a single '`'
addSon(result, newStrNode(nkStrLit, $marker))
Expand Down
7 changes: 5 additions & 2 deletions tests/ccgbugs/tforward_decl_only.nim
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,15 @@ type
a: cint
Foo2 = object
b: cint
Foo3 = object
c:int

proc f(foo: ptr Foo, foo2: ptr Foo2): cint =
proc f(foo: ptr Foo, foo2: ptr Foo2, foo3: ptr Foo3): cint =
if foo != nil: {.emit: "`result` = `foo`->a;".}
if foo2 != nil: {.emit: [result, " = ", foo2[], ".b;"].}
if foo3 != nil: {.emit: "`result` = `foo3[]`.c + `foo3.c`;".}

discard f(nil, nil)
discard f(nil, nil, nil)


# bug #7392
Expand Down

0 comments on commit 8935dde

Please sign in to comment.