diff --git a/compiler/sigmatch.nim b/compiler/sigmatch.nim index a42ff8c3e0459..d46abff007ac0 100644 --- a/compiler/sigmatch.nim +++ b/compiler/sigmatch.nim @@ -2143,7 +2143,7 @@ proc paramTypesMatchAux(m: var TCandidate, f, a: PType, if r == isGeneric: inc(m.genericMatches, 2) else: - inc(m.typeClassMatches) + inc(m.typeClassMatches, 2) if arg.typ == nil: result = arg elif skipTypes(arg.typ, abstractVar-{tyTypeDesc}).kind == tyTuple or @@ -2181,7 +2181,7 @@ proc paramTypesMatchAux(m: var TCandidate, f, a: PType, params = nkFormalParams.newTree(p.emptyNode), name = p.emptyNode, pattern = p.emptyNode, genericParams = p.emptyNode, pragmas = p.emptyNode, exceptions = p.emptyNode), {}) if f.kind == tyBuiltInTypeClass: - inc m.genericMatches, 2 + inc m.typeClassMatches, 2 put(m, f, lifted.typ) inc m.convMatches return implicitConv(nkHiddenStdConv, f, lifted, m, c) diff --git a/lib/pure/json.nim b/lib/pure/json.nim index d0b1a4051b2d1..1f96bdfd69012 100644 --- a/lib/pure/json.nim +++ b/lib/pure/json.nim @@ -390,6 +390,11 @@ proc `[]=`*(obj: JsonNode, key: string, val: JsonNode) {.inline.} = assert(obj.kind == JObject) obj.fields[key] = val +proc `%`*(o: enum): JsonNode = + ## Construct a JsonNode that represents the specified enum value as a + ## string. Creates a new `JString JsonNode`. + result = %($o) + proc `%`*[T: object](o: T): JsonNode = ## Construct JsonNode from tuples and objects. result = newJObject() @@ -402,11 +407,6 @@ proc `%`*(o: ref object): JsonNode = else: result = %(o[]) -proc `%`*(o: enum): JsonNode = - ## Construct a JsonNode that represents the specified enum value as a - ## string. Creates a new `JString JsonNode`. - result = %($o) - proc toJsonImpl(x: NimNode): NimNode = case x.kind of nnkBracket: # array diff --git a/tests/generics/t6840.nim b/tests/generics/t6840.nim deleted file mode 100644 index f7303cc73c582..0000000000000 --- a/tests/generics/t6840.nim +++ /dev/null @@ -1,23 +0,0 @@ -proc foo(x: int): int = 1 -proc foo[T](x: T): int = 2 -proc foo[T: int16](x: T): int = 3 # generic constrained to type - -proc bar(x: int): int = 1 -proc bar[T](x: T): int = 2 -proc bar[T: int16](x: T): int = 3 # generic constrained to typeclass - -proc baz(x: int): int = 1 -proc baz[T](x: T): int = 2 -proc baz(x: int16): int = 3 # parameter constrained to typeclass - -doAssert foo(1) == 1 -doAssert foo(1'i8) == 2 -doAssert foo(1'i16) == 3 # OK - -doAssert bar(1) == 1 -doAssert bar(1'i8) == 2 -doAssert bar(1'i16) == 3 # DOES NOT COMPILE - "ambigous call" ??? - -doAssert baz(1) == 1 -doAssert baz(1'i8) == 2 -doAssert baz(1'i16) == 3 # OK diff --git a/tests/stdlib/tstrformat.nim b/tests/stdlib/tstrformat.nim index 50499f0b29a71..b44a11e68d10a 100644 --- a/tests/stdlib/tstrformat.nim +++ b/tests/stdlib/tstrformat.nim @@ -115,7 +115,7 @@ proc main() = let data1 = [1'i64, 10000'i64, 10000000'i64] let data2 = [10000000'i64, 100'i64, 1'i64] - proc formatValue[T: array|seq|openArray](result: var string; value: T; specifier: string) = + proc formatValue(result: var string; value: (array|seq|openArray); specifier: string) = result.add "[" for i, it in value: if i != 0: