Skip to content

Commit 8ab8573

Browse files
committed
Remove -preview=tuples flag.
1 parent a1544f7 commit 8ab8573

12 files changed

Lines changed: 17 additions & 33 deletions

File tree

changelog/dmd.tuple-unpacking.dd

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@ Tuple unpacking is now supported!
22

33
D now supports tuple unpacking for variable declarations, `foreach` loops, and function literal
44
template parameters.
5-
This feature is available as a preview and can be enabled with the `-preview=tuples` compiler switch.
65
It allows extracting multiple values from a tuple or compile-time sequence directly into distinct variables.
76

87
-------
9-
// Requires -preview=tuples
108
import std.typecons : tuple;
119

1210
void main()

compiler/include/dmd/globals.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,6 @@ struct Param
227227
// Implementation: https://github.com/dlang/dmd/pull/9817
228228
FeatureState safer; // safer by default (more @safe checks in unattributed code)
229229
// https://github.com/WalterBright/documents/blob/38f0a846726b571f8108f6e63e5e217b91421c86/safer.md
230-
FeatureState tuples; // Tuple unpacking
231230

232231
FeatureState noSharedAccess; // read/write access to shared memory objects
233232
d_bool previewIn; // `in` means `[ref] scope const`, accepts rvalues
@@ -335,7 +334,6 @@ struct CompileEnv
335334
DString time;
336335
DString vendor;
337336
DString timestamp;
338-
d_bool tuples;
339337
d_bool previewIn;
340338
d_bool transitionIn;
341339
d_bool ddocOutput;

compiler/src/dmd/cli.d

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1111,9 +1111,6 @@ dmd -cov -unittest myprog.d
11111111
Feature("safer", "safer",
11121112
"more safety checks by default",
11131113
"https://github.com/WalterBright/documents/blob/38f0a846726b571f8108f6e63e5e217b91421c86/safer.md", true, false),
1114-
Feature("tuples", "tuples",
1115-
"enable tuple unpacking",
1116-
"https://github.com/tgehr/DIPs/blob/tuple-syntax/DIPs/DIP1xxx-tg.md"),
11171114
Feature("nosharedaccess", "noSharedAccess",
11181115
"disable access to shared memory objects",
11191116
"https://dlang.org/spec/const3.html#shared"),

compiler/src/dmd/globals.d

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,6 @@ extern (C++) struct Param
207207
// Implementation: https://github.com/dlang/dmd/pull/9817
208208
FeatureState safer; // safer by default (more @safe checks in unattributed code)
209209
// https://github.com/WalterBright/documents/blob/38f0a846726b571f8108f6e63e5e217b91421c86/safer.md
210-
FeatureState tuples; // Tuple unpacking
211210
FeatureState noSharedAccess; // read/write access to shared memory objects
212211
bool previewIn; // `in` means `[ref] scope const`, accepts rvalues
213212
bool inclusiveInContracts; // 'in' contracts of overridden methods must be a superset of parent contract

compiler/src/dmd/lexer.d

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ struct CompileEnv
4747
const(char)[] vendor; /// __VENDOR__
4848
const(char)[] timestamp; /// __TIMESTAMP__
4949

50-
bool tuples; //// tuple unpacking syntax
5150
bool previewIn; /// `in` means `[ref] scope const`, accepts rvalues
5251
bool transitionIn; /// `-transition=in` is active, `in` parameters are listed
5352
bool ddocOutput; /// collect embedded documentation comments

compiler/src/dmd/main.d

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,6 @@ private int tryMain(const(char)[][] argv, out Param params)
205205
}
206206
global.errorSink.errorLimit = global.params.v.errorLimit;
207207

208-
global.compileEnv.tuples = params.tuples == FeatureState.enabled;
209208
global.compileEnv.previewIn = params.previewIn;
210209
global.compileEnv.transitionIn = params.v.vin;
211210
global.compileEnv.ddocOutput = params.ddoc.doOutput;

compiler/src/dmd/parse.d

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer
337337
auto next = peek(t);
338338
if (next.value != TOK.leftParenthesis)
339339
return false;
340-
if (compileEnv.tuples && isTupleNotation(next))
340+
if (isTupleNotation(next))
341341
return false;
342342
return true;
343343
}
@@ -845,7 +845,7 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer
845845
{
846846
auto next = peek(&token);
847847
if (next.value != TOK.leftParenthesis ||
848-
compileEnv.tuples && peekPastParen(next).value == TOK.assign)
848+
peekPastParen(next).value == TOK.assign)
849849
{
850850
stc = STC.extern_;
851851
goto Lstc;
@@ -1098,7 +1098,7 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer
10981098

10991099
case TOK.leftParenthesis:
11001100
// confirm unpacking for better error messages:
1101-
if (compileEnv.tuples && peekPastParen(&token).value == TOK.assign)
1101+
if (peekPastParen(&token).value == TOK.assign)
11021102
goto Ldeclaration;
11031103
goto default;
11041104

@@ -1288,7 +1288,7 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer
12881288
* Parse auto declarations of the form:
12891289
* storageClass ident = init, ident = init, ... ;
12901290
* and return the array of them.
1291-
* Starts with token on the first ident, or '(' with -preview=tuples.
1291+
* Starts with token on the first ident, or '('
12921292
* Ends with scanner past closing ';'
12931293
*/
12941294
private AST.Dsymbols* parseAutoDeclarations(STC storageClass, const(char)* comment)
@@ -1302,7 +1302,6 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer
13021302
AST.Dsymbol s;
13031303
if (token.value == TOK.leftParenthesis)
13041304
{
1305-
assert(compileEnv.tuples);
13061305
s = parseUnpackDeclaration(storageClass, true);
13071306
if (!storageClass && token.value == TOK.comma)
13081307
{
@@ -3239,7 +3238,7 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer
32393238
if (tpl && !*tpl && hasAutoRefParam)
32403239
*tpl = new AST.TemplateParameters();
32413240

3242-
if (compileEnv.tuples && tpl && token.value == TOK.leftParenthesis)
3241+
if (tpl && token.value == TOK.leftParenthesis)
32433242
{
32443243
const tv2 = peekPastParen(&token).value;
32453244
if (tv2 == TOK.comma || tv2 == TOK.rightParenthesis || tv2 == TOK.dotDotDot)
@@ -4643,7 +4642,7 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer
46434642
{
46444643
auto next = peek(&token);
46454644
if (next.value != TOK.leftParenthesis ||
4646-
compileEnv.tuples && peekPastParen(next).value == TOK.assign)
4645+
peekPastParen(next).value == TOK.assign)
46474646
{
46484647
stc = STC.extern_;
46494648
goto L1;
@@ -4804,7 +4803,7 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer
48044803
* (int x, auto y) = initializer;
48054804
* storage_class (a, b, ...) = initializer;
48064805
*/
4807-
if (compileEnv.tuples && token.value == TOK.leftParenthesis &&
4806+
if (token.value == TOK.leftParenthesis &&
48084807
isTupleNotation(&token))
48094808
{
48104809
// TODO: can we merge this with the branch below?
@@ -5962,7 +5961,7 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer
59625961
goto Larg;
59635962
}
59645963
}
5965-
else if (compileEnv.tuples && token.value == TOK.leftParenthesis)
5964+
else if (token.value == TOK.leftParenthesis)
59665965
{
59675966
TOK after = peekPastParen(&token).value;
59685967
if (after == TOK.comma || after == TOK.semicolon)
@@ -6670,7 +6669,7 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer
66706669
case TOK.scope_:
66716670
auto next = peek(&token);
66726671
if (next.value != TOK.leftParenthesis ||
6673-
compileEnv.tuples && peekPastParen(next).value == TOK.assign)
6672+
peekPastParen(next).value == TOK.assign)
66746673
goto Ldeclaration; // scope used as storage class
66756674
nextToken();
66766675
check(TOK.leftParenthesis);

compiler/test/compilable/previewhelp.d

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ Upcoming language changes listed by -preview=name:
1414
=fixAliasThis when a symbol is resolved, check alias this scope before going to upper scopes (https://github.com/dlang/dmd/pull/8885)
1515
=rvaluerefparam enable rvalue arguments to ref parameters (https://gist.github.com/andralex/e5405a5d773f07f73196c05f8339435a)
1616
=safer more safety checks by default (https://github.com/WalterBright/documents/blob/38f0a846726b571f8108f6e63e5e217b91421c86/safer.md)
17-
=tuples enable tuple unpacking (https://github.com/tgehr/DIPs/blob/tuple-syntax/DIPs/DIP1xxx-tg.md)
1817
=nosharedaccess disable access to shared memory objects (https://dlang.org/spec/const3.html#shared)
1918
=in `in` on parameters means `scope const [ref]` and accepts rvalues (https://dlang.org/spec/function.html#in-params)
2019
=inclusiveincontracts 'in' contracts of overridden methods must be a superset of parent contract (https://dlang.org/changelog/2.095.0.html#inclusive-incontracts)

compiler/test/fail_compilation/unpack_semantic.d

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
/*
2-
REQUIRED_ARGS: -preview=tuples
32
TEST_OUTPUT:
43
---
5-
fail_compilation/unpack_semantic.d(18): Error: right hand side of unpack declaration must resolve to a tuple or expression sequence, not `int[]`
6-
fail_compilation/unpack_semantic.d(19): Error: incompatible number of components for unpack declaration (`2` vs. `3`)
7-
fail_compilation/unpack_semantic.d(22): Error: cannot specify `static` for individual components of an unpack declaration
8-
fail_compilation/unpack_semantic.d(23): Error: cannot specify `enum` for individual components of an unpack declaration
9-
fail_compilation/unpack_semantic.d(26): Error: cannot implicitly convert expression `3.0F` of type `float` to `int`
10-
fail_compilation/unpack_semantic.d(27): Error: cannot implicitly convert expression `7` of type `int` to `void*`
4+
fail_compilation/unpack_semantic.d(17): Error: right hand side of unpack declaration must resolve to a tuple or expression sequence, not `int[]`
5+
fail_compilation/unpack_semantic.d(18): Error: incompatible number of components for unpack declaration (`2` vs. `3`)
6+
fail_compilation/unpack_semantic.d(21): Error: cannot specify `static` for individual components of an unpack declaration
7+
fail_compilation/unpack_semantic.d(22): Error: cannot specify `enum` for individual components of an unpack declaration
8+
fail_compilation/unpack_semantic.d(25): Error: cannot implicitly convert expression `3.0F` of type `float` to `int`
9+
fail_compilation/unpack_semantic.d(26): Error: cannot implicitly convert expression `7` of type `int` to `void*`
1110
---
1211
*/
1312

compiler/test/fail_compilation/unpacking.d

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
REQUIRED_ARGS: -preview=tuples -vcolumns
2+
REQUIRED_ARGS: -vcolumns
33
TEST_OUTPUT:
44
---
55
fail_compilation/unpacking.d(30,14): Error: unpacked variable `b` needs a type or at least one storage class, did you mean `auto b`?

0 commit comments

Comments
 (0)