mirror of
https://github.com/nim-lang/Nim.git
synced 2026-06-06 20:04:18 +00:00
fixes #4432
This commit is contained in:
@@ -191,10 +191,6 @@ proc semConv(c: PContext, n: PNode): PNode =
|
||||
case status
|
||||
of convOK:
|
||||
# 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:
|
||||
result.sons[1] = fitNode(c, result.typ, result.sons[1])
|
||||
elif op.kind == nkPar and targetType.kind == tyTuple:
|
||||
@@ -202,8 +198,10 @@ proc semConv(c: PContext, n: PNode): PNode =
|
||||
of convNotNeedeed:
|
||||
message(n.info, hintConvFromXtoItselfNotNeeded, result.typ.typeToString)
|
||||
of convNotLegal:
|
||||
localError(n.info, errGenerated, msgKindToString(errIllegalConvFromXtoY)%
|
||||
[op.typ.typeToString, result.typ.typeToString])
|
||||
result = fitNode(c, result.typ, result.sons[1])
|
||||
if result == nil:
|
||||
localError(n.info, errGenerated, msgKindToString(errIllegalConvFromXtoY)%
|
||||
[op.typ.typeToString, result.typ.typeToString])
|
||||
else:
|
||||
for i in countup(0, sonsLen(op) - 1):
|
||||
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
|
||||
Reference in New Issue
Block a user