implement RFCs/294 ; disallow enum <=> enum conversion (#16351)
* fix https://github.com/nim-lang/RFCs/issues/294 ; disallow enum <=> enum conversion * fix the runnableExamples that was the instigator of this RFC * legacy -d:nimLegacyConvEnumEnum * use -d:nimLegacyConvEnumEnum in important_package nimgame2 * add test for enum cast * improve changelog * add changelog: Changes affecting backward compatibility * cleanup changelog * fix changelog
This commit is contained in:
parent
a807233aeb
commit
270964c487
9 changed files with 115 additions and 38 deletions
|
|
@ -163,6 +163,11 @@ proc checkConvertible(c: PContext, targetTyp: PType, src: PNode): TConvStatus =
|
|||
result = checkConversionBetweenObjects(d.skipTypes(abstractInst), s.skipTypes(abstractInst), pointers)
|
||||
elif (targetBaseTyp.kind in IntegralTypes) and
|
||||
(srcBaseTyp.kind in IntegralTypes):
|
||||
if targetTyp.kind == tyEnum and srcBaseTyp.kind == tyEnum:
|
||||
if c.config.isDefined("nimLegacyConvEnumEnum"):
|
||||
message(c.config, src.info, warnUser, "enum to enum conversion is now deprecated")
|
||||
else: result = convNotLegal
|
||||
# `elif` would be incorrect here
|
||||
if targetTyp.kind == tyBool:
|
||||
discard "convOk"
|
||||
elif targetTyp.isOrdinalType:
|
||||
|
|
|
|||
|
|
@ -137,7 +137,7 @@ proc guardGlobal(a: PEffects; n: PNode; guard: PSym) =
|
|||
# we allow accesses nevertheless in top level statements for
|
||||
# easier initialization:
|
||||
#if a.isTopLevel:
|
||||
# message(n.info, warnUnguardedAccess, renderTree(n))
|
||||
# message(a.config, n.info, warnUnguardedAccess, renderTree(n))
|
||||
#else:
|
||||
if not a.isTopLevel:
|
||||
localError(a.config, n.info, "unguarded access: " & renderTree(n))
|
||||
|
|
@ -478,7 +478,7 @@ proc getLockLevel(s: PSym): TLockLevel =
|
|||
result = 0.TLockLevel
|
||||
else:
|
||||
result = UnknownLockLevel
|
||||
#message(s.info, warnUser, "FOR THIS " & s.name.s)
|
||||
#message(??.config, s.info, warnUser, "FOR THIS " & s.name.s)
|
||||
|
||||
proc mergeLockLevels(tracked: PEffects, n: PNode, lockLevel: TLockLevel) =
|
||||
if lockLevel >= tracked.currLockLevel:
|
||||
|
|
@ -544,7 +544,7 @@ proc assumeTheWorst(tracked: PEffects; n: PNode; op: PType) =
|
|||
let lockLevel = if op.lockLevel == UnspecifiedLockLevel: UnknownLockLevel
|
||||
else: op.lockLevel
|
||||
#if lockLevel == UnknownLockLevel:
|
||||
# message(n.info, warnUser, "had to assume the worst here")
|
||||
# message(??.config, n.info, warnUser, "had to assume the worst here")
|
||||
mergeLockLevels(tracked, n, lockLevel)
|
||||
|
||||
proc isOwnedProcVar(n: PNode; owner: PSym): bool =
|
||||
|
|
|
|||
|
|
@ -1435,7 +1435,7 @@ proc genAddr(c: PCtx, n: PNode, dest: var TDest, flags: TGenFlags) =
|
|||
# permanent, so that it's not used for anything else:
|
||||
c.prc.slots[tmp].kind = slotTempPerm
|
||||
# XXX this is still a hack
|
||||
#message(n.info, warnUser, "suspicious opcode used")
|
||||
#message(c.congig, n.info, warnUser, "suspicious opcode used")
|
||||
else:
|
||||
gABC(c, n, opcAddrReg, dest, tmp)
|
||||
c.freeTemp(tmp)
|
||||
|
|
@ -1687,7 +1687,7 @@ proc genArrAccessOpcode(c: PCtx; n: PNode; dest: var TDest; opc: TOpcode;
|
|||
c.gABC(n, opcNodeToReg, dest, cc)
|
||||
c.freeTemp(cc)
|
||||
else:
|
||||
#message(n.info, warnUser, "argh")
|
||||
#message(c.config, n.info, warnUser, "argh")
|
||||
#echo "FLAGS ", flags, " ", fitsRegister(n.typ), " ", typeToString(n.typ)
|
||||
c.gABC(n, opc, dest, a, b)
|
||||
c.freeTemp(a)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue