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:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue