fixes #4537
This commit is contained in:
parent
de6198c747
commit
4d5c0027e6
2 changed files with 25 additions and 0 deletions
|
|
@ -1031,6 +1031,7 @@ proc typeRel(c: var TCandidate, f, aOrig: PType, doBind = true): TTypeRelation =
|
||||||
if x < isSubtype: return isNone
|
if x < isSubtype: return isNone
|
||||||
# 'and' implies minimum matching result:
|
# 'and' implies minimum matching result:
|
||||||
if x < result: result = x
|
if x < result: result = x
|
||||||
|
if result > isGeneric: result = isGeneric
|
||||||
bindingRet result
|
bindingRet result
|
||||||
|
|
||||||
of tyOr:
|
of tyOr:
|
||||||
|
|
@ -1041,6 +1042,7 @@ proc typeRel(c: var TCandidate, f, aOrig: PType, doBind = true): TTypeRelation =
|
||||||
# 'or' implies maximum matching result:
|
# 'or' implies maximum matching result:
|
||||||
if x > result: result = x
|
if x > result: result = x
|
||||||
if result >= isSubtype:
|
if result >= isSubtype:
|
||||||
|
if result > isGeneric: result = isGeneric
|
||||||
bindingRet result
|
bindingRet result
|
||||||
else:
|
else:
|
||||||
result = isNone
|
result = isNone
|
||||||
|
|
|
||||||
23
tests/converter/tor_in_converter.nim
Normal file
23
tests/converter/tor_in_converter.nim
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
discard """
|
||||||
|
output: '''test
|
||||||
|
test'''
|
||||||
|
"""
|
||||||
|
# bug #4537
|
||||||
|
|
||||||
|
# nim js --d:nodejs
|
||||||
|
|
||||||
|
type
|
||||||
|
Str = distinct string
|
||||||
|
|
||||||
|
when true:
|
||||||
|
# crashes
|
||||||
|
converter convert(s: string | cstring): Str = Str($s)
|
||||||
|
else:
|
||||||
|
# works!
|
||||||
|
converter convert(s: string): Str = Str($s)
|
||||||
|
converter convert(s: cstring): Str = Str($s)
|
||||||
|
|
||||||
|
proc echoStr(s: Str) = echo s.string
|
||||||
|
|
||||||
|
echoStr("test")
|
||||||
|
echoStr("test".cstring)
|
||||||
Loading…
Add table
Add a link
Reference in a new issue