From 888917669cd4a6e3c81f1da42dd9ccd43f9dbb1b Mon Sep 17 00:00:00 2001 From: Dennis Date: Thu, 16 Jan 2025 08:20:06 +0100 Subject: [PATCH] Remove debug() / version() integers (#20713) --- .../dmd.deprecation-version-debug-number.dd | 4 ++ compiler/src/dmd/mars.d | 24 +----------- compiler/src/dmd/parse.d | 39 ++----------------- compiler/test/fail_compilation/diag11198.d | 14 ++----- .../fail_compilation/diag_debug_conditional.d | 4 +- compiler/test/fail_compilation/test13786.d | 12 ++---- compiler/test/runnable/lexer.d | 17 -------- 7 files changed, 19 insertions(+), 95 deletions(-) create mode 100644 changelog/dmd.deprecation-version-debug-number.dd diff --git a/changelog/dmd.deprecation-version-debug-number.dd b/changelog/dmd.deprecation-version-debug-number.dd new file mode 100644 index 0000000000..3a07614d58 --- /dev/null +++ b/changelog/dmd.deprecation-version-debug-number.dd @@ -0,0 +1,4 @@ +Integers in debug or version statements have been removed from the language + +These were deprecated in 2.101. +Use `-debug=identifier` and `-version=identifier` instead for versions set on the command line, or `version = identifier;` and `debug = identifier;` for versions set in code at global scope. diff --git a/compiler/src/dmd/mars.d b/compiler/src/dmd/mars.d index cc9086d6cf..0bad6027c7 100644 --- a/compiler/src/dmd/mars.d +++ b/compiler/src/dmd/mars.d @@ -1591,20 +1591,10 @@ bool parseCommandLine(const ref Strings arguments, const size_t argc, ref Param { // Parse: // -debug - // -debug=number // -debug=identifier if (p[6] == '=') { - if (isdigit(cast(char)p[7])) - { - if (!params.debuglevel.parseDigits(p.toDString()[7 .. $])) - goto Lerror; - - // @@@DEPRECATED_2.111@@@ - // Deprecated in 2.101, remove in 2.111 - eSink.deprecation(Loc.initial, "`-debug=number` is deprecated, use debug identifiers instead"); - } - else if (Identifier.isValidIdentifier(p + 7)) + if (Identifier.isValidIdentifier(p + 7)) { DebugCondition.addGlobalIdent((p + 7).toDString()); } @@ -1619,20 +1609,10 @@ bool parseCommandLine(const ref Strings arguments, const size_t argc, ref Param else if (startsWith(p + 1, "version")) // https://dlang.org/dmd.html#switch-version { // Parse: - // -version=number // -version=identifier if (p[8] == '=') { - if (isdigit(cast(char)p[9])) - { - if (!params.versionlevel.parseDigits(p.toDString()[9 .. $])) - goto Lerror; - - // @@@DEPRECATED_2.111@@@ - // Deprecated in 2.101, remove in 2.111 - eSink.deprecation(Loc.initial, "`-version=number` is deprecated, use version identifiers instead"); - } - else if (Identifier.isValidIdentifier(p + 9)) + if (Identifier.isValidIdentifier(p + 9)) { VersionCondition.addGlobalIdent((p+9).toDString()); } diff --git a/compiler/src/dmd/parse.d b/compiler/src/dmd/parse.d index 415d57824d..b851b9aafe 100644 --- a/compiler/src/dmd/parse.d +++ b/compiler/src/dmd/parse.d @@ -2257,17 +2257,9 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer nextToken(); if (token.value == TOK.identifier) s = new AST.DebugSymbol(token.loc, token.ident); - else if (token.value == TOK.int32Literal || token.value == TOK.int64Literal) - { - // @@@DEPRECATED_2.111@@@ - // Deprecated in 2.101, remove in 2.111 - deprecation("`debug = ` is deprecated, use debug identifiers instead"); - - s = new AST.DebugSymbol(token.loc, cast(uint)token.unsvalue); - } else { - error("identifier or integer expected, not `%s`", token.toChars()); + error("identifier expected, not `%s`", token.toChars()); s = null; } nextToken(); @@ -2292,16 +2284,8 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer if (token.value == TOK.identifier) id = token.ident; - else if (token.value == TOK.int32Literal || token.value == TOK.int64Literal) - { - // @@@DEPRECATED_2.111@@@ - // Deprecated in 2.101, remove in 2.111 - deprecation("`debug( )` is deprecated, use debug identifiers instead"); - - level = cast(uint)token.unsvalue; - } else - error("identifier or integer expected inside `debug(...)`, not `%s`", token.toChars()); + error("identifier expected inside `debug(...)`, not `%s`", token.toChars()); loc = token.loc; nextToken(); check(TOK.rightParenthesis); @@ -2318,16 +2302,9 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer nextToken(); if (token.value == TOK.identifier) s = new AST.VersionSymbol(token.loc, token.ident); - else if (token.value == TOK.int32Literal || token.value == TOK.int64Literal) - { - // @@@DEPRECATED_2.111@@@ - // Deprecated in 2.101, remove in 2.111 - deprecation("`version = ` is deprecated, use version identifiers instead"); - s = new AST.VersionSymbol(token.loc, cast(uint)token.unsvalue); - } else { - error("identifier or integer expected, not `%s`", token.toChars()); + error("identifier expected, not `%s`", token.toChars()); s = null; } nextToken(); @@ -2357,20 +2334,12 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer loc = token.loc; if (token.value == TOK.identifier) id = token.ident; - else if (token.value == TOK.int32Literal || token.value == TOK.int64Literal) - { - // @@@DEPRECATED_2.111@@@ - // Deprecated in 2.101, remove in 2.111 - deprecation("`version( )` is deprecated, use version identifiers instead"); - - level = cast(uint)token.unsvalue; - } else if (token.value == TOK.unittest_) id = Identifier.idPool(Token.toString(TOK.unittest_)); else if (token.value == TOK.assert_) id = Identifier.idPool(Token.toString(TOK.assert_)); else - error("identifier or integer expected inside `version(...)`, not `%s`", token.toChars()); + error("identifier expected inside `version(...)`, not `%s`", token.toChars()); nextToken(); check(TOK.rightParenthesis); } diff --git a/compiler/test/fail_compilation/diag11198.d b/compiler/test/fail_compilation/diag11198.d index 1be0f1e85a..7f8979ccb3 100644 --- a/compiler/test/fail_compilation/diag11198.d +++ b/compiler/test/fail_compilation/diag11198.d @@ -1,14 +1,10 @@ /* TEST_OUTPUT: --- -fail_compilation/diag11198.d(17): Error: version `blah` declaration must be at module level -fail_compilation/diag11198.d(18): Error: debug `blah` declaration must be at module level -fail_compilation/diag11198.d(19): Deprecation: `version = ` is deprecated, use version identifiers instead -fail_compilation/diag11198.d(19): Error: version `1` level declaration must be at module level -fail_compilation/diag11198.d(20): Deprecation: `debug = ` is deprecated, use debug identifiers instead -fail_compilation/diag11198.d(20): Error: debug `2` level declaration must be at module level -fail_compilation/diag11198.d(21): Error: identifier or integer expected, not `""` -fail_compilation/diag11198.d(22): Error: identifier or integer expected, not `""` +fail_compilation/diag11198.d(13): Error: version `blah` declaration must be at module level +fail_compilation/diag11198.d(14): Error: debug `blah` declaration must be at module level +fail_compilation/diag11198.d(15): Error: identifier expected, not `""` +fail_compilation/diag11198.d(16): Error: identifier expected, not `""` --- */ @@ -16,8 +12,6 @@ void main() { version = blah; debug = blah; - version = 1; - debug = 2; version = ""; debug = ""; } diff --git a/compiler/test/fail_compilation/diag_debug_conditional.d b/compiler/test/fail_compilation/diag_debug_conditional.d index 99884c70c4..51df97c803 100644 --- a/compiler/test/fail_compilation/diag_debug_conditional.d +++ b/compiler/test/fail_compilation/diag_debug_conditional.d @@ -1,8 +1,8 @@ /** TEST_OUTPUT: --- -fail_compilation/diag_debug_conditional.d(1): Error: identifier or integer expected inside `debug(...)`, not `alias` -fail_compilation/diag_debug_conditional.d(2): Error: identifier or integer expected inside `version(...)`, not `alias` +fail_compilation/diag_debug_conditional.d(1): Error: identifier expected inside `debug(...)`, not `alias` +fail_compilation/diag_debug_conditional.d(2): Error: identifier expected inside `version(...)`, not `alias` fail_compilation/diag_debug_conditional.d(3): Error: declaration expected following attribute, not end of file --- */ diff --git a/compiler/test/fail_compilation/test13786.d b/compiler/test/fail_compilation/test13786.d index 73ec588c77..5a873bf9c9 100644 --- a/compiler/test/fail_compilation/test13786.d +++ b/compiler/test/fail_compilation/test13786.d @@ -1,21 +1,15 @@ /* TEST_OUTPUT: --- -fail_compilation/test13786.d(16): Deprecation: `debug = ` is deprecated, use debug identifiers instead -fail_compilation/test13786.d(18): Deprecation: `version = ` is deprecated, use version identifiers instead -fail_compilation/test13786.d(16): Error: debug `123` level declaration must be at module level -fail_compilation/test13786.d(17): Error: debug `abc` declaration must be at module level -fail_compilation/test13786.d(18): Error: version `123` level declaration must be at module level -fail_compilation/test13786.d(19): Error: version `abc` declaration must be at module level -fail_compilation/test13786.d(22): Error: template instance `test13786.T!()` error instantiating +fail_compilation/test13786.d(12): Error: debug `abc` declaration must be at module level +fail_compilation/test13786.d(13): Error: version `abc` declaration must be at module level +fail_compilation/test13786.d(16): Error: template instance `test13786.T!()` error instantiating --- */ template T() { - debug = 123; debug = abc; - version = 123; version = abc; } diff --git a/compiler/test/runnable/lexer.d b/compiler/test/runnable/lexer.d index 18ad055add..0e1068a428 100644 --- a/compiler/test/runnable/lexer.d +++ b/compiler/test/runnable/lexer.d @@ -1,14 +1,3 @@ -// REQUIRED_ARGS: -verrors=simple -/* -TEST_OUTPUT: ---- -runnable/lexer.d(86): Deprecation: `version( )` is deprecated, use version identifiers instead -runnable/lexer.d(87): Deprecation: `debug( )` is deprecated, use debug identifiers instead ---- -*/ - -/*********************************************************/ - void test6() { string s = q"(foo(xxx))"; @@ -82,12 +71,6 @@ void test8() /*********************************************************/ -// https://issues.dlang.org/show_bug.cgi?id=6584 -version(9223372036854775807){} -debug(9223372036854775807){} - -/*********************************************************/ - enum e13102=184467440737095516153.6L; /*********************************************************/