diff options
-rw-r--r-- | compiler/condsyms.nim | 1 | ||||
-rw-r--r-- | compiler/sigmatch.nim | 8 | ||||
-rw-r--r-- | compiler/types.nim | 2 | ||||
-rw-r--r-- | lib/system.nim | 4 | ||||
-rw-r--r-- | tests/stdlib/tnilecho.nim | 4 |
5 files changed, 12 insertions, 7 deletions
diff --git a/compiler/condsyms.nim b/compiler/condsyms.nim index 1f147b4a8..0955a84ae 100644 --- a/compiler/condsyms.nim +++ b/compiler/condsyms.nim @@ -75,3 +75,4 @@ proc initDefines*(symbols: StringTableRef) = defineSymbol("nimIncrSeqV3") defineSymbol("nimAshr") defineSymbol("nimNoNilSeqs") + defineSymbol("nimNoNilSeqs2") diff --git a/compiler/sigmatch.nim b/compiler/sigmatch.nim index d779152d2..f206119ec 100644 --- a/compiler/sigmatch.nim +++ b/compiler/sigmatch.nim @@ -1355,11 +1355,7 @@ proc typeRelImpl(c: var TCandidate, f, aOrig: PType, else: result = isEqual of tyNil: result = f.allowsNil - of tyString: - if optNilSeqs in c.c.config.options or c.magic != mEqCString: - result = isConvertible - else: - result = isNone + of tyString: result = isConvertible of tyPtr: # ptr[Tag, char] is not convertible to 'cstring' for now: if a.len == 1: @@ -1819,7 +1815,7 @@ proc userConvMatch(c: PContext, m: var TCandidate, f, a: PType, # see tests/tgenericconverter: let srca = typeRel(m, src, a) if srca notin {isEqual, isGeneric, isSubtype}: continue - + let constraint = c.converters[i].typ.n[1].sym.constraint if not constraint.isNil and not matchNodeKinds(constraint, arg): continue diff --git a/compiler/types.nim b/compiler/types.nim index 8a120b609..80624502c 100644 --- a/compiler/types.nim +++ b/compiler/types.nim @@ -1200,7 +1200,7 @@ proc typeAllowedAux(marker: var IntSet, typ: PType, kind: TSymKind, tyNone, tyForward, tyFromExpr: result = t of tyNil: - if kind != skConst: result = t + if kind != skConst and kind != skParam: result = t of tyString, tyBool, tyChar, tyEnum, tyInt..tyUInt64, tyCString, tyPointer: result = nil of tyOrdinal: diff --git a/lib/system.nim b/lib/system.nim index c730167ed..0a721d940 100644 --- a/lib/system.nim +++ b/lib/system.nim @@ -4048,6 +4048,10 @@ proc `==`*(x, y: cstring): bool {.magic: "EqCString", noSideEffect, elif x.isNil or y.isNil: result = false else: result = strcmp(x, y) == 0 +when defined(nimNoNilSeqs2): + proc `==`*(x: string; y: type(nil)): bool {.error.} = discard + proc `==`*(x: type(nil); y: string): bool {.error.} = discard + template closureScope*(body: untyped): untyped = ## Useful when creating a closure in a loop to capture local loop variables by ## their current iteration values. Example: diff --git a/tests/stdlib/tnilecho.nim b/tests/stdlib/tnilecho.nim index 0f8a38438..ec8d71dab 100644 --- a/tests/stdlib/tnilecho.nim +++ b/tests/stdlib/tnilecho.nim @@ -1,2 +1,6 @@ +discard """ + output: "" +""" + var x = @["1", "", "3"] doAssert $x == """@["1", "", "3"]""" |