Skip to content

Commit 4f34842

Browse files
committed
PRTEMP
1 parent 835f135 commit 4f34842

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

compiler/options.nim

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,8 @@ type
191191
strictFuncs,
192192
views,
193193
strictNotNil
194+
oldImplicitCstringConv,
195+
# deprecated features start with `old` # PRTEMP: legacy
194196

195197
LegacyFeature* = enum
196198
allowSemcheckedAstModification,
@@ -369,6 +371,14 @@ template setErrorMaxHighMaybe*(conf: ConfigRef) =
369371
## do not stop after first error (but honor --errorMax if provided)
370372
assignIfDefault(conf.errorMax, high(int))
371373

374+
template toSet(a: typedesc[enum]): untyped = {a.low..a.high}
375+
376+
const
377+
FeatureDepr* = {oldImplicitCstringConv}
378+
# can't use `LegacyFeature` because we want to be able to localize
379+
# to a context, eg {.push experimental: "oldImplicitCstringConv".} .. {.pop.}
380+
FeatureExp* = Feature.toSet - FeatureDepr
381+
372382
proc setNoteDefaults*(conf: ConfigRef, note: TNoteKind, enabled = true) =
373383
template fun(op) =
374384
conf.notes.op note

compiler/sigmatch.nim

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1405,11 +1405,10 @@ proc typeRel(c: var TCandidate, f, aOrig: PType,
14051405
of tyNil: result = f.allowsNil
14061406
of tyString: result = isConvertible
14071407
of tyPtr:
1408-
# https://github.com/nim-lang/Nim/issues/13790
1409-
when true:
1410-
result = isNone # PRTEMP
1411-
else:
1408+
if oldImplicitCstringConv in c.c.features:
1409+
# issue #13790
14121410
# ptr[Tag, char] is not convertible to 'cstring' for now:
1411+
# xxx: aren't memory regions not used anymore?
14131412
if a.len == 1:
14141413
let pointsTo = a[0].skipTypes(abstractInst)
14151414
if pointsTo.kind == tyChar: result = isConvertible
@@ -1419,6 +1418,11 @@ proc typeRel(c: var TCandidate, f, aOrig: PType,
14191418
skipTypes(pointsTo[0], {tyRange}).kind in {tyInt..tyInt64} and
14201419
pointsTo[1].kind == tyChar:
14211420
result = isConvertible
1421+
# if result == isConvertible:
1422+
# message(c.config, a.info, warnOldImplicitCstringConv)
1423+
# warnProveInit
1424+
else:
1425+
result = isNone
14221426
else: discard
14231427

14241428
of tyEmpty, tyVoid:

0 commit comments

Comments
 (0)