mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-28 17:04:41 +00:00
fixes #24736 The VM can produce integer nodes with no types as set elements, which are later reannotated in `semmacrosanity.annotateType`. However the case of ranges was not handled properly. Not sure why this is a regression, probably unrelated but will have to see the bisect result to make sure. Note. Originally tried to fix this in `opcInclRange`, generated for and only for range expressions in set constructors, this seems to add the range node directly to the set node without checking if it has overlap with the existing elements by calling `nimsets` so an expression like `{cctNone, cctNone..cctHeader}` can produce `{0, 0..5}`. Doesn't seem to cause problems but `opcIncl` for single elements does check for overlap. Something else to note is that integer nodes produced by `nimsets` have proper types, so another option instead of relying on semmacrosanity to fix this would be to make `opcIncl` and `opcInclRange` call `nimsets` to add to the set node, but this might lose performance.
18 lines
447 B
Nim
18 lines
447 B
Nim
# issue #24736
|
|
|
|
import std/setutils
|
|
|
|
type CcsCatType = enum cctNone, cctHeader, cctIndex, cctSetup, cctUnk1, cctStream
|
|
|
|
block: # original issue
|
|
const CCS_CAT_TYPES = fullSet(CcsCatType)
|
|
proc test(t: int): bool = t.CcsCatType in CCS_CAT_TYPES
|
|
discard test(5)
|
|
|
|
block: # minimized
|
|
func foo(): set[CcsCatType] =
|
|
{cctNone..cctHeader}
|
|
const CCS_CAT_TYPES = foo()
|
|
proc test(t: int): bool = t.CcsCatType in CCS_CAT_TYPES
|
|
discard test(5)
|