Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #4165(static parameters + emit) #17613

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion compiler/pragmas.nim
Original file line number Diff line number Diff line change
@@ -551,7 +551,7 @@ proc semAsmOrEmit*(con: PContext, n: PNode, marker: char): PNode =
var str = n[1].strVal
if str == "":
localError(con.config, n.info, "empty 'asm' statement")
return
return errorNode(con, n)
# now parse the string literal and substitute symbols:
var a = 0
while true:
@@ -567,6 +567,9 @@ proc semAsmOrEmit*(con: PContext, n: PNode, marker: char): PNode =
var e = searchInScopes(con, getIdent(con.cache, sub), amb)
# XXX what to do here if 'amb' is true?
if e != nil:
if e.kind == skParam and e.typ != nil and e.typ.kind == tyStatic:
localError(con.config, n.info, "static parameters cannot be accessed at runtime")
return errorNode(con, n)
incl(e.flags, sfUsed)
result.add newSymNode(e)
else:
7 changes: 7 additions & 0 deletions tests/statictypes/t4165.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
discard """
errormsg: "static parameters cannot be accessed at runtime"
"""

proc printStr(s: static[string]) =
{.emit: "puts(`s`->data);" .}
printStr("hello static")