diff options
author | LemonBoy <LemonBoy@users.noreply.github.com> | 2018-07-09 15:02:48 +0200 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2018-07-09 15:02:48 +0200 |
commit | c6671776a16127be30a627d1672fee9897a2320f (patch) | |
tree | 499fc4dd8e0a3a39573cca534087373667d3c332 | |
parent | dec97924a4bb6a719380475de46485ce71eeb56c (diff) | |
download | Nim-c6671776a16127be30a627d1672fee9897a2320f.tar.gz |
Reset typedescMatched before paramTypesMatch (#8250)
The flag should not be carried out across different parameters. Fixes #7794
-rw-r--r-- | compiler/sigmatch.nim | 3 | ||||
-rw-r--r-- | tests/generics/t7794.nim | 15 |
2 files changed, 18 insertions, 0 deletions
diff --git a/compiler/sigmatch.nim b/compiler/sigmatch.nim index f9d1edc89..09f7f23b5 100644 --- a/compiler/sigmatch.nim +++ b/compiler/sigmatch.nim @@ -2231,6 +2231,7 @@ proc matchesAux(c: PContext, n, nOrig: PNode, m.state = csNoMatch return m.baseTypeMatch = false + m.typedescMatched = false n.sons[a].sons[1] = prepareOperand(c, formal.typ, n.sons[a].sons[1]) n.sons[a].typ = n.sons[a].sons[1].typ var arg = paramTypesMatch(m, formal.typ, n.sons[a].typ, @@ -2266,6 +2267,7 @@ proc matchesAux(c: PContext, n, nOrig: PNode, # beware of the side-effects in 'prepareOperand'! So only do it for # varargs matching. See tests/metatype/tstatic_overloading. m.baseTypeMatch = false + m.typedescMatched = false incl(marker, formal.position) n.sons[a] = prepareOperand(c, formal.typ, n.sons[a]) var arg = paramTypesMatch(m, formal.typ, n.sons[a].typ, @@ -2300,6 +2302,7 @@ proc matchesAux(c: PContext, n, nOrig: PNode, addSon(container, n.sons[a]) else: m.baseTypeMatch = false + m.typedescMatched = false n.sons[a] = prepareOperand(c, formal.typ, n.sons[a]) var arg = paramTypesMatch(m, formal.typ, n.sons[a].typ, n.sons[a], nOrig.sons[a]) diff --git a/tests/generics/t7794.nim b/tests/generics/t7794.nim new file mode 100644 index 000000000..b295da865 --- /dev/null +++ b/tests/generics/t7794.nim @@ -0,0 +1,15 @@ +discard """ +output: ''' +10 +2.0 +''' +""" + +type + Data*[T:SomeNumber, U:SomeReal] = ref object + x*: T + value*: U + +var d = Data[int, float64](x:10.int, value:2'f64) +echo d.x +echo d.value |