[editions] Make body after contract an error (#16382)

* [editions] Make `body` after contract an error

* Mention --help in build.d module comment

* Add ASTBase.Module.edition property, always Edition.legacy for now
This commit is contained in:
Nick Treleaven 2024-04-18 08:26:20 +01:00 committed by GitHub
parent 3b3d496210
commit dca92a75b7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 18 additions and 3 deletions

View file

@ -5,6 +5,8 @@ DMD builder
Usage:
./build.d dmd
See `--help` for targets.
detab, tolf, install targets - require the D Language Tools (detab.exe, tolf.exe)
https://github.com/dlang/tools.

View file

@ -1397,6 +1397,7 @@ struct ASTBase
const FileName srcfile;
const(char)[] arg;
Edition edition = Edition.legacy;
extern (D) this(const ref Loc loc, const(char)[] filename, Identifier ident, int doDocComment, int doHdrGen)
{

View file

@ -1212,9 +1212,10 @@ bool parseCommandLine(const ref Strings arguments, const size_t argc, ref Param
params.warnings = DiagnosticReporting.inform;
else if (arg == "-wo") // https://dlang.org/dmd.html#switch-wo
{
// Obsolete features has been obsoleted until a DIP for "additions"
// Obsolete features has been obsoleted until a DIP for "editions"
// has been drafted and ratified in the language spec.
// Rather, these old features will just be accepted without warning.
// See also: @__edition_latest_do_not_use
}
else if (arg == "-O") // https://dlang.org/dmd.html#switch-O
driverParams.optimize = true;

View file

@ -9589,9 +9589,9 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer
void usageOfBodyKeyword()
{
version (none) // disable obsolete warning
if (mod.edition >= Edition.v2024)
{
eSink.warning(token.loc, "usage of identifer `body` as a keyword is obsolete. Use `do` instead.");
eSink.error(token.loc, "usage of identifer `body` as a keyword is obsolete. Use `do` instead.");
}
}
}

View file

@ -0,0 +1,11 @@
/*
TEST_OUTPUT:
---
fail_compilation/obsolete_body.d(11): Error: usage of identifer `body` as a keyword is obsolete. Use `do` instead.
---
*/
@__edition_latest_do_not_use
module m;
void test()
in { } body { }