Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
- Enabling `-d:nimPreviewSlimSystem` removes the import of `channels_builtin` in
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 `mainmodule` and `m` options are removed.
Expand Down
1 change: 1 addition & 0 deletions compiler/nim.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ define:booting
define:nimcore
define:nimPreviewFloatRoundtrip
define:nimPreviewSlimSystem
define:nimPreviewCstringConversion
define:nimPreviewRangeDefault
threads:off

Expand Down
22 changes: 12 additions & 10 deletions compiler/sigmatch.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 2 additions & 1 deletion tests/stdlib/config.nims
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
switch("styleCheck", "usages")
switch("styleCheck", "error")
switch("define", "nimPreviewSlimSystem")
switch("define", "nimPreviewSlimSystem")
switch("define", "nimPreviewCstringConversion")
3 changes: 2 additions & 1 deletion tests/tools/config.nims
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
--d:nimPreviewSlimSystem
--d:nimPreviewSlimSystem
--d:nimPreviewCstringConversion