mirror of
https://github.com/nim-lang/Nim.git
synced 2026-06-06 03:44:14 +00:00
whitelist prev types to reuse in newOrPrevType (#24899)
fixes #24898 A type is only overwritten if it is definitely a forward type, partial object (symbol marked `sfForward`) or a magic type. Maybe worse for performance but should be more correct. Another option might be to provide a different value for `prev` for the `preserveSym` case but then we cannot easily ignore only nominal type nodes.
This commit is contained in:
@@ -41,6 +41,16 @@ foo:
|
||||
discard Bar[int](x: 123)
|
||||
discard Bar[string](x: "abc")
|
||||
|
||||
type
|
||||
Generic1[T] = object
|
||||
Generic2[T] = ref int
|
||||
Generic3[T] = ref Generic1[T]
|
||||
Generic4[T] = Generic2[T]
|
||||
GenericInst1 = Generic1[int]
|
||||
GenericInst2 = Generic2[int]
|
||||
GenericInst3 = Generic3[int]
|
||||
GenericInst4 = Generic4[int]
|
||||
|
||||
# regression test:
|
||||
template templ(): untyped =
|
||||
proc injected() {.inject.} = discard
|
||||
@@ -49,7 +59,13 @@ foo:
|
||||
type TestInject = templ()
|
||||
var x1: TestInject
|
||||
injected() # normally works
|
||||
|
||||
echo $NONE
|
||||
echo a
|
||||
var x2: TestInject
|
||||
injected()
|
||||
|
||||
block: # issue #24898
|
||||
type V[W] = object
|
||||
template g(d: int) = discard d
|
||||
g((; type J = V[int]; 0))
|
||||
|
||||
Reference in New Issue
Block a user