fixes #4432
This commit is contained in:
parent
ce91a1b25d
commit
1ddd2a3865
2 changed files with 17 additions and 6 deletions
|
|
@ -191,10 +191,6 @@ proc semConv(c: PContext, n: PNode): PNode =
|
||||||
case status
|
case status
|
||||||
of convOK:
|
of convOK:
|
||||||
# handle SomeProcType(SomeGenericProc)
|
# handle SomeProcType(SomeGenericProc)
|
||||||
# XXX: This needs fixing. checkConvertible uses typeRel internally, but
|
|
||||||
# doesn't bother to perform the work done in paramTypeMatchAux/fitNode
|
|
||||||
# so we are redoing the typeRel work here. Why does semConv exist as a
|
|
||||||
# separate proc from fitNode?
|
|
||||||
if op.kind == nkSym and op.sym.isGenericRoutine:
|
if op.kind == nkSym and op.sym.isGenericRoutine:
|
||||||
result.sons[1] = fitNode(c, result.typ, result.sons[1])
|
result.sons[1] = fitNode(c, result.typ, result.sons[1])
|
||||||
elif op.kind == nkPar and targetType.kind == tyTuple:
|
elif op.kind == nkPar and targetType.kind == tyTuple:
|
||||||
|
|
@ -202,8 +198,10 @@ proc semConv(c: PContext, n: PNode): PNode =
|
||||||
of convNotNeedeed:
|
of convNotNeedeed:
|
||||||
message(n.info, hintConvFromXtoItselfNotNeeded, result.typ.typeToString)
|
message(n.info, hintConvFromXtoItselfNotNeeded, result.typ.typeToString)
|
||||||
of convNotLegal:
|
of convNotLegal:
|
||||||
localError(n.info, errGenerated, msgKindToString(errIllegalConvFromXtoY)%
|
result = fitNode(c, result.typ, result.sons[1])
|
||||||
[op.typ.typeToString, result.typ.typeToString])
|
if result == nil:
|
||||||
|
localError(n.info, errGenerated, msgKindToString(errIllegalConvFromXtoY)%
|
||||||
|
[op.typ.typeToString, result.typ.typeToString])
|
||||||
else:
|
else:
|
||||||
for i in countup(0, sonsLen(op) - 1):
|
for i in countup(0, sonsLen(op) - 1):
|
||||||
let it = op.sons[i]
|
let it = op.sons[i]
|
||||||
|
|
|
||||||
13
tests/converter/texplicit_conversion.nim
Normal file
13
tests/converter/texplicit_conversion.nim
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
discard """
|
||||||
|
output: "234"
|
||||||
|
"""
|
||||||
|
|
||||||
|
# bug #4461
|
||||||
|
|
||||||
|
import strutils
|
||||||
|
|
||||||
|
converter toInt(s: string): int =
|
||||||
|
result = parseInt(s)
|
||||||
|
|
||||||
|
let x = (int)"234"
|
||||||
|
echo x
|
||||||
Loading…
Add table
Add a link
Reference in a new issue