diff options
author | Araq <rumpf_a@web.de> | 2015-01-13 20:55:03 +0100 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2015-01-13 20:56:31 +0100 |
commit | 20774ad43c84048ffedb1b54625effc28b27a71d (patch) | |
tree | 354912c3bda96c2bf0208609a26978e268f8941c /compiler | |
parent | c94f5bfb0612b1ed63ceddd156dbee968b6bf896 (diff) | |
download | Nim-20774ad43c84048ffedb1b54625effc28b27a71d.tar.gz |
fixes the integer conversion regressions
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/msgs.nim | 2 | ||||
-rw-r--r-- | compiler/semcall.nim | 3 | ||||
-rw-r--r-- | compiler/sigmatch.nim | 31 |
3 files changed, 20 insertions, 16 deletions
diff --git a/compiler/msgs.nim b/compiler/msgs.nim index 7f4f81dd0..17b2c4606 100644 --- a/compiler/msgs.nim +++ b/compiler/msgs.nim @@ -672,7 +672,7 @@ proc toFileLine*(info: TLineInfo): string {.inline.} = proc toFileLineCol*(info: TLineInfo): string {.inline.} = result = info.toFilename & "(" & $info.line & "," & $info.col & ")" -template `$`*(info: TLineInfo): expr = toFileLineCol(info) +proc `$`*(info: TLineInfo): string = toFileLineCol(info) proc `??`* (info: TLineInfo, filename: string): bool = # only for debugging purposes diff --git a/compiler/semcall.nim b/compiler/semcall.nim index a712cc195..23362151b 100644 --- a/compiler/semcall.nim +++ b/compiler/semcall.nim @@ -72,6 +72,9 @@ proc pickBestCandidate(c: PContext, headSymbol: PNode, if cmp < 0: best = z # x is better than the best so far elif cmp == 0: alt = z # x is as good as the best so far else: discard + #if sym.name.s == "shl" and (n.info ?? "net.nim"): + # echo "Matches ", n.info, " ", typeToString(sym.typ) + # writeMatches(z) sym = nextOverloadIter(o, c, headSymbol) proc notFoundError*(c: PContext, n: PNode, errors: CandidateErrors) = diff --git a/compiler/sigmatch.nim b/compiler/sigmatch.nim index 647b14792..3c6cd248e 100644 --- a/compiler/sigmatch.nim +++ b/compiler/sigmatch.nim @@ -205,10 +205,11 @@ proc cmpCandidates*(a, b: TCandidate): int = proc writeMatches*(c: TCandidate) = writeln(stdout, "exact matches: " & $c.exactMatches) + writeln(stdout, "generic matches: " & $c.genericMatches) writeln(stdout, "subtype matches: " & $c.subtypeMatches) - writeln(stdout, "conv matches: " & $c.convMatches) writeln(stdout, "intconv matches: " & $c.intConvMatches) - writeln(stdout, "generic matches: " & $c.genericMatches) + writeln(stdout, "conv matches: " & $c.convMatches) + writeln(stdout, "inheritance: " & $c.inheritancePenalty) proc argTypeToString(arg: PNode; prefer: TPreferedDesc): string = if arg.kind in nkSymChoices: @@ -267,7 +268,7 @@ proc concreteType(c: TCandidate, t: PType): PType = else: result = t # Note: empty is valid here -proc handleRange(f, a: PType, validconv: set[TTypeKind]): TTypeRelation = +proc handleRange(f, a: PType, min, max: TTypeKind): TTypeRelation = if a.kind == f.kind: result = isEqual else: @@ -281,9 +282,9 @@ proc handleRange(f, a: PType, validconv: set[TTypeKind]): TTypeRelation = # integer literal in the proper range; we want ``i16 + 4`` to stay an # ``int16`` operation so we declare the ``4`` pseudo-equal to int16 result = isFromIntLit - elif f.kind == tyInt and k in {tyInt8..tyInt32, tyUint8..tyUInt16}: + elif f.kind == tyInt and k in {tyInt8..tyInt32}: result = isIntConv - elif k in validconv: + elif k >= min and k <= max: result = isConvertible elif a.kind == tyRange and a.sons[0].kind in {tyInt..tyInt64, tyUInt8..tyUInt32} and @@ -663,16 +664,16 @@ proc typeRel(c: var TCandidate, f, aOrig: PType, doBind = true): TTypeRelation = result = isIntConv elif isConvertibleToRange(skipTypes(f, {tyRange}), a): result = isConvertible # a convertible to f - of tyInt: result = handleRange(f, a, {tyInt8..tyInt32,tyUInt8..tyUInt16}) - of tyInt8: result = handleRange(f, a, {tyInt8}) - of tyInt16: result = handleRange(f, a, {tyInt8..tyInt16,tyUInt8}) - of tyInt32: result = handleRange(f, a, {tyInt8..tyInt32,tyUInt8..tyUInt16}) - of tyInt64: result = handleRange(f, a, {tyInt..tyInt64,tyUInt8..tyUInt32}) - of tyUInt: result = handleRange(f, a, {tyUInt8..tyUInt32}) - of tyUInt8: result = handleRange(f, a, {tyUInt8}) - of tyUInt16: result = handleRange(f, a, {tyUInt8..tyUInt16}) - of tyUInt32: result = handleRange(f, a, {tyUInt8..tyUInt32}) - of tyUInt64: result = handleRange(f, a, {tyUInt..tyUInt64}) + of tyInt: result = handleRange(f, a, tyInt8, tyInt32) + of tyInt8: result = handleRange(f, a, tyInt8, tyInt8) + of tyInt16: result = handleRange(f, a, tyInt8, tyInt16) + of tyInt32: result = handleRange(f, a, tyInt8, tyInt32) + of tyInt64: result = handleRange(f, a, tyInt, tyInt64) + of tyUInt: result = handleRange(f, a, tyUInt8, tyUInt32) + of tyUInt8: result = handleRange(f, a, tyUInt8, tyUInt8) + of tyUInt16: result = handleRange(f, a, tyUInt8, tyUInt16) + of tyUInt32: result = handleRange(f, a, tyUInt8, tyUInt32) + of tyUInt64: result = handleRange(f, a, tyUInt, tyUInt64) of tyFloat: result = handleFloatRange(f, a) of tyFloat32: result = handleFloatRange(f, a) of tyFloat64: result = handleFloatRange(f, a) |