mirror of
https://github.com/nim-lang/Nim.git
synced 2026-07-30 04:07:55 +00:00
fix #2614 improve error message when array of proc calling convention mismatch
This commit is contained in:
@@ -1572,6 +1572,7 @@ proc getProcConvMismatch*(c: ConfigRef, f, a: PType, rel = isNone): (set[ProcCon
|
||||
of isInferred: result[1] = isInferredConvertible
|
||||
of isBothMetaConvertible: result[1] = isBothMetaConvertible
|
||||
elif result[1] != isNone: result[1] = isConvertible
|
||||
else: result[0].incl pcmDifferentCallConv
|
||||
else:
|
||||
result[1] = isNone
|
||||
result[0].incl pcmDifferentCallConv
|
||||
@@ -1607,6 +1608,25 @@ proc addPragmaAndCallConvMismatch*(message: var string, formal, actual: PType, c
|
||||
expectedPragmas.setLen(max(0, expectedPragmas.len - 2)) # Remove ", "
|
||||
message.add "\n Pragma mismatch: got '{.$1.}', but expected '{.$2.}'." % [gotPragmas, expectedPragmas]
|
||||
|
||||
proc processPragmaAndCallConvMismatch(msg: var string, formal, actual: PType, conf: ConfigRef) =
|
||||
if formal.kind == tyProc and actual.kind == tyProc:
|
||||
msg.addPragmaAndCallConvMismatch(formal, actual, conf)
|
||||
case compatibleEffects(formal, actual)
|
||||
of efCompat: discard
|
||||
of efRaisesDiffer:
|
||||
msg.add "\n.raise effects differ"
|
||||
of efRaisesUnknown:
|
||||
msg.add "\n.raise effect is 'can raise any'"
|
||||
of efTagsDiffer:
|
||||
msg.add "\n.tag effects differ"
|
||||
of efTagsUnknown:
|
||||
msg.add "\n.tag effect is 'any tag allowed'"
|
||||
of efLockLevelsDiffer:
|
||||
msg.add "\nlock levels differ"
|
||||
of efEffectsDelayed:
|
||||
msg.add "\n.effectsOf annotations differ"
|
||||
of efTagsIllegal:
|
||||
msg.add "\n.notTag catched an illegal effect"
|
||||
|
||||
proc typeMismatch*(conf: ConfigRef; info: TLineInfo, formal, actual: PType, n: PNode) =
|
||||
if formal.kind != tyError and actual.kind != tyError:
|
||||
@@ -1626,25 +1646,18 @@ proc typeMismatch*(conf: ConfigRef; info: TLineInfo, formal, actual: PType, n: P
|
||||
msg.add "\n"
|
||||
msg.add " but expected '$1'" % x
|
||||
if verbose: msg.addDeclaredLoc(conf, formal)
|
||||
|
||||
if formal.kind == tyProc and actual.kind == tyProc:
|
||||
msg.addPragmaAndCallConvMismatch(formal, actual, conf)
|
||||
case compatibleEffects(formal, actual)
|
||||
of efCompat: discard
|
||||
of efRaisesDiffer:
|
||||
msg.add "\n.raise effects differ"
|
||||
of efRaisesUnknown:
|
||||
msg.add "\n.raise effect is 'can raise any'"
|
||||
of efTagsDiffer:
|
||||
msg.add "\n.tag effects differ"
|
||||
of efTagsUnknown:
|
||||
msg.add "\n.tag effect is 'any tag allowed'"
|
||||
of efLockLevelsDiffer:
|
||||
msg.add "\nlock levels differ"
|
||||
of efEffectsDelayed:
|
||||
msg.add "\n.effectsOf annotations differ"
|
||||
of efTagsIllegal:
|
||||
msg.add "\n.notTag catched an illegal effect"
|
||||
var a = formal
|
||||
var b = actual
|
||||
if formal.kind == tyArray and actual.kind == tyArray:
|
||||
a = formal[1]
|
||||
b = actual[1]
|
||||
processPragmaAndCallConvMismatch(msg, a, b, conf)
|
||||
elif formal.kind == tySequence and actual.kind == tySequence:
|
||||
a = formal[0]
|
||||
b = actual[0]
|
||||
processPragmaAndCallConvMismatch(msg, a, b, conf)
|
||||
else:
|
||||
processPragmaAndCallConvMismatch(msg, a, b, conf)
|
||||
localError(conf, info, msg)
|
||||
|
||||
proc isTupleRecursive(t: PType, cycleDetector: var IntSet): bool =
|
||||
|
||||
Reference in New Issue
Block a user