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

misc nimvm #157

Open
1 task
timotheecour opened this issue May 5, 2020 · 1 comment
Open
1 task

misc nimvm #157

timotheecour opened this issue May 5, 2020 · 1 comment
Labels

Comments

@timotheecour
Copy link
Owner

timotheecour commented May 5, 2020

when not defined(nimscript): reduces to when true because nimscript always runs in nimvm

Yes but it semantic checks the else branch. We dealt with this already. If you change this to when true you get undeclared identifier nimCmpMem

D20200524T194136

  when notJSnotNims:
    const nimCmpMem = 1
  proc cmp(x, y: string): int =
    when nimvm:
      discard
    else:
      when not defined(nimscript):
        discard nimCmpMem

wondering whether nim-lang#13038 would help...

links

[Meta] Generics/Static early symbol resolution · Issue #8677 · nim-lang/Nim

example where my previous proposed if nimct: doens't work:

nim-lang#13038 (comment)

whereas this works:

when defined case2:
  proc c_printf(frmt: cstring): cint {.importc: "printf", header: "<stdio.h>", varargs, discardable.}
  proc main() =
    when nimvm: echo "in nimvm"
    else:
      echo "notin nimvm"
      c_printf("hello\n")
  static: main()
  main()
@timotheecour
Copy link
Owner Author

timotheecour commented Nov 25, 2020

see whether we can overload by nimvm vs rt:

proc fn(): int {.nimvm.} = 1
proc fn(): int {.nimvm:off.} = 2
proc main=
	doAssert fn() == 2
	static: doAssert fn() == 1

links

  • tfTriggersCompileTime
  # constant folding that is necessary for correctness of semantic pass:
  if callee.magic != mNone and callee.magic in ctfeWhitelist and n.typ != nil:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant