* fixes #7600 * fix wrong logic
This commit is contained in:
parent
397e173139
commit
e4aa140d22
3 changed files with 42 additions and 2 deletions
|
|
@ -1388,8 +1388,13 @@ proc typeRelImpl(c: var TCandidate, f, aOrig: PType,
|
||||||
|
|
||||||
var aAsObject = roota.lastSon
|
var aAsObject = roota.lastSon
|
||||||
|
|
||||||
if fKind in {tyRef, tyPtr} and aAsObject.kind == fKind:
|
if fKind in {tyRef, tyPtr}:
|
||||||
aAsObject = aAsObject.base
|
if aAsObject.kind == tyObject:
|
||||||
|
# bug #7600, tyObject cannot be passed
|
||||||
|
# as argument to tyRef/tyPtr
|
||||||
|
return isNone
|
||||||
|
elif aAsObject.kind == fKind:
|
||||||
|
aAsObject = aAsObject.base
|
||||||
|
|
||||||
if aAsObject.kind == tyObject:
|
if aAsObject.kind == tyObject:
|
||||||
let baseType = aAsObject.base
|
let baseType = aAsObject.base
|
||||||
|
|
|
||||||
18
tests/typerel/t7600_1.nim
Normal file
18
tests/typerel/t7600_1.nim
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
discard """
|
||||||
|
errormsg: "type mismatch: got <Thin[system.int]>"
|
||||||
|
nimout: '''t7600_1.nim(18, 6) Error: type mismatch: got <Thin[system.int]>
|
||||||
|
but expected one of:
|
||||||
|
proc test[T](x: Paper[T])
|
||||||
|
|
||||||
|
expression: test tn'''
|
||||||
|
"""
|
||||||
|
|
||||||
|
type
|
||||||
|
Paper[T] = ref object of RootObj
|
||||||
|
thickness: T
|
||||||
|
Thin[T] = object of Paper[T]
|
||||||
|
|
||||||
|
proc test[T](x: Paper[T]) = discard
|
||||||
|
|
||||||
|
var tn = Thin[int]()
|
||||||
|
test tn
|
||||||
17
tests/typerel/t7600_2.nim
Normal file
17
tests/typerel/t7600_2.nim
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
discard """
|
||||||
|
errormsg: "type mismatch: got <Thin>"
|
||||||
|
nimout: '''t7600_2.nim(17, 6) Error: type mismatch: got <Thin>
|
||||||
|
but expected one of:
|
||||||
|
proc test(x: Paper)
|
||||||
|
|
||||||
|
expression: test tn'''
|
||||||
|
"""
|
||||||
|
|
||||||
|
type
|
||||||
|
Paper = ref object of RootObj
|
||||||
|
Thin = object of Paper
|
||||||
|
|
||||||
|
proc test(x: Paper) = discard
|
||||||
|
|
||||||
|
var tn = Thin()
|
||||||
|
test tn
|
||||||
Loading…
Add table
Add a link
Reference in a new issue