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
Compiler internalError when using operations on empty untyped built-in set #23496
Comments
While what you say is true the compiler rejecting |
I agree that it may be acceptable to reject binary operations between empty set literal and typed set, because they are declared requiring same type is macro someMacro(body: untyped): untyped =
template helperGenerateChecks(s: untyped): untyped =
proc check(val: int): bool =
when card(s) > 0:
result = true # do some expensive check
else:
result = false # do some short-circuit
var someSet = newNimNode(nnkCurly)
# fill someSet based on body, possibly empty
result = getAst(helperGenerateChecks(someSet)) And binary operations on empty sets are useful when comparing two sets generated by macros |
Description
Operations on built-in set literal
{}
cause compiler internal error.Code examples:
Also, according to manual
So, binary operations with empty set literal and typed set should also work:
Nim Version
Since nim
0.19.0
todevel
, introduced in #7558Directly tested version:
Current Output
Expected Output
Possible Solution
For operations only on empty set literal it is enough to add early return in
toBitSet
incompiler/nimsets.nim
Additional Information
No response
The text was updated successfully, but these errors were encountered: