Bug 24088 – A nested function that returns a tuple that is written with short syntax function does not want to compile.

Status
RESOLVED
Resolution
FIXED
Severity
minor
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Windows
Creation time
2023-08-16T14:37:32Z
Last change time
2023-09-16T07:31:13Z
Keywords
pull, rejects-valid
Assigned to
No Owner
Creator
andreiD

Attachments

IDFilenameSummaryContent-TypeSize
1886ft.dprogramm codetext/plain418

Comments

Comment #0 by andreiD — 2023-08-16T14:37:32Z
Created attachment 1886 programm code dmd 2.104
Comment #1 by nick — 2023-08-16T20:07:17Z
Reduced: ``` import std.typecons; void main() { // Error: found `opp` when expecting `;` following statement `Tuple!(int, int)` on line Tuple!(int, int) opp(int x, int y) => tuple(x + y, x - y); // no ok } ``` BTW that error message has been improved in git master, it now says: ft.d(12): Error: found `opp` when expecting `;` following expression ft.d(12): expression: `Tuple!(int, int)`
Comment #2 by nick — 2023-08-16T20:12:28Z
Reduced: ``` struct S(T) {} void main() { S!int f() => S!int(); } ``` I think I have a fix for isDeclarator in parse.d, will submit tomorrow.
Comment #3 by dlang-bot — 2023-08-16T23:05:08Z
@maxhaton created dlang/dmd pull request #15542 "Fix Issue 24088 - Nested functions using the shortened syntax were no…" fixing this issue: - Fix Issue 24088 - Nested functions using the shortened syntax were not recognized correctly as declarations. The fix was simply to amend `isDeclarator` to look for TOK.goesTo (i.e. `=>`) https://github.com/dlang/dmd/pull/15542
Comment #4 by dlang-bot — 2023-08-17T10:33:11Z
dlang/dmd pull request #15542 "Fix Issue 24088 - Nested functions using the shortened syntax were no…" was merged into stable: - 2504a1fdd429abf85fca02885ba527d741e70098 by mhh: Fix Issue 24088 - Nested functions using the shortened syntax were not recognized correctly as declarations. The fix was simply to amend `isDeclarator` to look for TOK.goesTo (i.e. `=>`) https://github.com/dlang/dmd/pull/15542
Comment #5 by dlang-bot — 2023-09-16T07:31:13Z
dlang/dmd pull request #15609 "merge stable" was merged into master: - e3eccfe9a5d721ea5dd1e4ab1d9bff7c6ae91ac4 by mhh: Fix Issue 24088 - Nested functions using the shortened syntax were not recognized correctly as declarations. The fix was simply to amend `isDeclarator` to look for TOK.goesTo (i.e. `=>`) https://github.com/dlang/dmd/pull/15609