* 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
|
|
@ -42,6 +42,8 @@
|
||||||
- Enabling `-d:nimPreviewSlimSystem` removes the import of `channels_builtin` in
|
- Enabling `-d:nimPreviewSlimSystem` removes the import of `channels_builtin` in
|
||||||
in the `system` module.
|
in the `system` module.
|
||||||
|
|
||||||
|
- Enabling `-d:nimPreviewCstringConversion`, `ptr char`, `ptr array[N, char]` and `ptr UncheckedArray[N, char]` don't support conversion to cstring anymore.
|
||||||
|
|
||||||
- The `gc:v2` option is removed.
|
- The `gc:v2` option is removed.
|
||||||
|
|
||||||
- The `mainmodule` and `m` options are removed.
|
- The `mainmodule` and `m` options are removed.
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ define:booting
|
||||||
define:nimcore
|
define:nimcore
|
||||||
define:nimPreviewFloatRoundtrip
|
define:nimPreviewFloatRoundtrip
|
||||||
define:nimPreviewSlimSystem
|
define:nimPreviewSlimSystem
|
||||||
|
define:nimPreviewCstringConversion
|
||||||
define:nimPreviewRangeDefault
|
define:nimPreviewRangeDefault
|
||||||
threads:off
|
threads:off
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1391,16 +1391,18 @@ proc typeRel(c: var TCandidate, f, aOrig: PType,
|
||||||
of tyNil: result = f.allowsNil
|
of tyNil: result = f.allowsNil
|
||||||
of tyString: result = isConvertible
|
of tyString: result = isConvertible
|
||||||
of tyPtr:
|
of tyPtr:
|
||||||
# ptr[Tag, char] is not convertible to 'cstring' for now:
|
if isDefined(c.c.config, "nimPreviewCstringConversion"):
|
||||||
if a.len == 1:
|
result = isNone
|
||||||
let pointsTo = a[0].skipTypes(abstractInst)
|
else:
|
||||||
if pointsTo.kind == tyChar: result = isConvertible
|
if a.len == 1:
|
||||||
elif pointsTo.kind == tyUncheckedArray and pointsTo[0].kind == tyChar:
|
let pointsTo = a[0].skipTypes(abstractInst)
|
||||||
result = isConvertible
|
if pointsTo.kind == tyChar: result = isConvertible
|
||||||
elif pointsTo.kind == tyArray and firstOrd(nil, pointsTo[0]) == 0 and
|
elif pointsTo.kind == tyUncheckedArray and pointsTo[0].kind == tyChar:
|
||||||
skipTypes(pointsTo[0], {tyRange}).kind in {tyInt..tyInt64} and
|
result = isConvertible
|
||||||
pointsTo[1].kind == tyChar:
|
elif pointsTo.kind == tyArray and firstOrd(nil, pointsTo[0]) == 0 and
|
||||||
result = isConvertible
|
skipTypes(pointsTo[0], {tyRange}).kind in {tyInt..tyInt64} and
|
||||||
|
pointsTo[1].kind == tyChar:
|
||||||
|
result = isConvertible
|
||||||
else: discard
|
else: discard
|
||||||
|
|
||||||
of tyEmpty, tyVoid:
|
of tyEmpty, tyVoid:
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
switch("styleCheck", "usages")
|
switch("styleCheck", "usages")
|
||||||
switch("styleCheck", "error")
|
switch("styleCheck", "error")
|
||||||
switch("define", "nimPreviewSlimSystem")
|
switch("define", "nimPreviewSlimSystem")
|
||||||
|
switch("define", "nimPreviewCstringConversion")
|
||||||
|
|
@ -1 +1,2 @@
|
||||||
--d:nimPreviewSlimSystem
|
--d:nimPreviewSlimSystem
|
||||||
|
--d:nimPreviewCstringConversion
|
||||||
Loading…
Add table
Add a link
Reference in a new issue