diff --git a/compiler/semfold.nim b/compiler/semfold.nim index f690615aca..55cdc334c7 100644 --- a/compiler/semfold.nim +++ b/compiler/semfold.nim @@ -30,7 +30,12 @@ proc newIntNodeT(intVal: BiggestInt, n: PNode): PNode = case skipTypes(n.typ, abstractVarRange).kind of tyInt: result = newIntNode(nkIntLit, intVal) - result.typ = getIntLitType(result) + # See bug #6989. 'pred' et al only produce an int literal type if the + # original type was 'int', not a distinct int etc. + if n.typ.kind == tyInt: + result.typ = getIntLitType(result) + else: + result.typ = n.typ # hrm, this is not correct: 1 + high(int) shouldn't produce tyInt64 ... #setIntLitType(result) of tyChar: diff --git a/lib/system.nim b/lib/system.nim index 2c0617e4d5..4e071e802a 100644 --- a/lib/system.nim +++ b/lib/system.nim @@ -318,7 +318,7 @@ type Slice*[T] = HSlice[T, T] ## an alias for ``HSlice[T, T]`` proc `..`*[T, U](a: T, b: U): HSlice[T, U] {.noSideEffect, inline, magic: "DotDot".} = - ## `slice`:idx: operator that constructs an interval ``[a, b]``, both `a` + ## binary `slice`:idx: operator that constructs an interval ``[a, b]``, both `a` ## and `b` are inclusive. Slices can also be used in the set constructor ## and in ordinal case statements, but then they are special-cased by the ## compiler. @@ -326,7 +326,7 @@ proc `..`*[T, U](a: T, b: U): HSlice[T, U] {.noSideEffect, inline, magic: "DotDo result.b = b proc `..`*[T](b: T): HSlice[int, T] {.noSideEffect, inline, magic: "DotDot".} = - ## `slice`:idx: operator that constructs an interval ``[default(int), b]`` + ## unary `slice`:idx: operator that constructs an interval ``[default(int), b]`` result.b = b when not defined(niminheritable): @@ -677,12 +677,12 @@ proc `<`*[T](x: Ordinal[T]): T {.magic: "UnaryLt", noSideEffect, deprecated.} ## write ``0 ..< 10`` instead of ``0 .. < 10`` (look at the spacing). ## For ``