Implement -edition=YYYY semantics#22248
Conversation
Set `Module.edition` in constructor. Make `-edition=YYYYfilename` an error as it does nothing (and also wrongly sets `params.edition`). Allow a larger `-edition` to override a module declaration's edition.
|
Thanks for your pull request and interest in making D better, @ntrel! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please see CONTRIBUTING.md for more information. If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment. Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog. Testing this PR locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub run digger -- build "master + dmd#22248" |
compiler/src/dmd/parse.d
Outdated
| } | ||
| mod.edition = cast(Edition)edition; | ||
| // ModuleDeclaration edition can't lower -edition flag's edition | ||
| if (edition > mod.edition) |
There was a problem hiding this comment.
Yes it can lower it.
The edition switch is only for overriding the default edition (D2/legacy).
There was a problem hiding this comment.
This DIP also recommends a -E switch that allows the user to specify a default target edition for all imported modules in a given path. This target overrides the default edition and the -edition flag, if present, for modules in the given path. An example:
The purpose of the switch is for build managers like dub.
|
I'll repeat myself on the issue. The behaviour of the edition switch was purposefully decided not to override the module declaration; as-is, this PR cannot be accepted. |
OK, fixed. |
Note: switch added in dlang#22248.
Set
Module.editionin constructor.Make
-edition=YYYYfilenamean error as it does nothing (and also wrongly setsparams.edition).Allow a larger
-editionvalue to override a module declaration's edition. (I think this is more useful than erroring). Note: this case is not mentioned in the DIP AFAICT - @atilaneves?Fixes #22245.