* fix =#13790 ptr char (+friends) should not implicitly convert to cstring * Apply suggestions from code review * first round; compiles on windows * nimPreviewSlimSystem * conversion is unsafe, cast needed * fixes more tests * fixes asyncnet * another try another error * last one * true * one more * why bugs didn't show at once * add `nimPreviewCstringConversion` switch * typo Co-authored-by: xflywind <43030857+xflywind@users.noreply.github.com>
This commit is contained in:
parent
ef29987781
commit
27a38a9fce
5 changed files with 19 additions and 12 deletions
|
|
@ -1391,16 +1391,18 @@ proc typeRel(c: var TCandidate, f, aOrig: PType,
|
|||
of tyNil: result = f.allowsNil
|
||||
of tyString: result = isConvertible
|
||||
of tyPtr:
|
||||
# ptr[Tag, char] is not convertible to 'cstring' for now:
|
||||
if a.len == 1:
|
||||
let pointsTo = a[0].skipTypes(abstractInst)
|
||||
if pointsTo.kind == tyChar: result = isConvertible
|
||||
elif pointsTo.kind == tyUncheckedArray and pointsTo[0].kind == tyChar:
|
||||
result = isConvertible
|
||||
elif pointsTo.kind == tyArray and firstOrd(nil, pointsTo[0]) == 0 and
|
||||
skipTypes(pointsTo[0], {tyRange}).kind in {tyInt..tyInt64} and
|
||||
pointsTo[1].kind == tyChar:
|
||||
result = isConvertible
|
||||
if isDefined(c.c.config, "nimPreviewCstringConversion"):
|
||||
result = isNone
|
||||
else:
|
||||
if a.len == 1:
|
||||
let pointsTo = a[0].skipTypes(abstractInst)
|
||||
if pointsTo.kind == tyChar: result = isConvertible
|
||||
elif pointsTo.kind == tyUncheckedArray and pointsTo[0].kind == tyChar:
|
||||
result = isConvertible
|
||||
elif pointsTo.kind == tyArray and firstOrd(nil, pointsTo[0]) == 0 and
|
||||
skipTypes(pointsTo[0], {tyRange}).kind in {tyInt..tyInt64} and
|
||||
pointsTo[1].kind == tyChar:
|
||||
result = isConvertible
|
||||
else: discard
|
||||
|
||||
of tyEmpty, tyVoid:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue