Skip to content

Commit

Permalink
PRTEMP
Browse files Browse the repository at this point in the history
  • Loading branch information
timotheecour committed Apr 16, 2021
1 parent 835f135 commit 4f34842
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
10 changes: 10 additions & 0 deletions compiler/options.nim
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,8 @@ type
strictFuncs,
views,
strictNotNil
oldImplicitCstringConv,
# deprecated features start with `old` # PRTEMP: legacy

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

template toSet(a: typedesc[enum]): untyped = {a.low..a.high}

const
FeatureDepr* = {oldImplicitCstringConv}
# can't use `LegacyFeature` because we want to be able to localize
# to a context, eg {.push experimental: "oldImplicitCstringConv".} .. {.pop.}
FeatureExp* = Feature.toSet - FeatureDepr

proc setNoteDefaults*(conf: ConfigRef, note: TNoteKind, enabled = true) =
template fun(op) =
conf.notes.op note
Expand Down
12 changes: 8 additions & 4 deletions compiler/sigmatch.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1405,11 +1405,10 @@ proc typeRel(c: var TCandidate, f, aOrig: PType,
of tyNil: result = f.allowsNil
of tyString: result = isConvertible
of tyPtr:
# https://github.com/nim-lang/Nim/issues/13790
when true:
result = isNone # PRTEMP
else:
if oldImplicitCstringConv in c.c.features:
# issue #13790
# ptr[Tag, char] is not convertible to 'cstring' for now:
# xxx: aren't memory regions not used anymore?
if a.len == 1:
let pointsTo = a[0].skipTypes(abstractInst)
if pointsTo.kind == tyChar: result = isConvertible
Expand All @@ -1419,6 +1418,11 @@ proc typeRel(c: var TCandidate, f, aOrig: PType,
skipTypes(pointsTo[0], {tyRange}).kind in {tyInt..tyInt64} and
pointsTo[1].kind == tyChar:
result = isConvertible
# if result == isConvertible:
# message(c.config, a.info, warnOldImplicitCstringConv)
# warnProveInit
else:
result = isNone
else: discard

of tyEmpty, tyVoid:
Expand Down

0 comments on commit 4f34842

Please sign in to comment.