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

Using an untyped template parameter in if statement's condition causes compile error #573

Open
demotomohiro opened this issue Feb 18, 2025 · 1 comment

Comments

@demotomohiro
Copy link
Collaborator

mytests/testuntyped.nim:

template foo(cond: untyped) =
  if cond:
    discard
$ ./bin/nimony c mytests/testuntyped.nim 
bin/nimsem  --isSystem m nifcache/sysvq0asl.1.nif nifcache/sysvq0asl.2.nif nifcache/sysvq0asl.2.idx.nif
bin/nimsem  m nifcache/tes4xq6tf1.1.nif nifcache/tes4xq6tf1.2.nif nifcache/tes4xq6tf1.2.idx.nif
Traceback (most recent call last)
src/nimony/nimsem.nim(116) nimsem
src/nimony/nimsem.nim(113) handleCmdLine
src/nimony/nimsem.nim(50) singleModule
src/nimony/sem.nim(5657) semcheck
src/nimony/sem.nim(765) semStmt
src/nimony/sem.nim(5314) semExpr
src/nimony/nimony_model.nim(3350) semProc
src/nimony/sem.nim(731) semProcBody
src/nimony/sem.nim(714) semStmtsExprImpl
src/nimony/sem.nim(5371) semExpr
src/nimony/sem.nim(3617) semIf
src/nimony/sem.nim(638) semBoolExpr
src/nimony/sembasics.nim(169) buildErr
src/nimony/sembasics.nim(157) buildErr
mytests/testuntyped.nim(3, 5) Error: expected `bool` but got: (untyped)
expected `bool` but got: (untyped)

assert template in syncio module cannot be compiled because of this issue.

@Araq
Copy link
Member

Araq commented Feb 19, 2025

For the time being, this should have been:

template foo(cond: bool) =
  if cond:
    discard

So .. an easy fix.

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

No branches or pull requests

2 participants