June 21, 2023 [Issue 23999] literal suffixes dont mix well with template instantiations | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=23999 --- Comment #9 from Dennis <dkorpel@live.nl> --- (In reply to Nick Treleaven from comment #8) > No reasonable person's preference can allow one of these suffixes right next to an identifier, because people read the suffix as part of the identifier. I agree, but it's not the compiler's job to enforce readable code. This is a valid statement, though no reasonable person would write this: ``` for ({{}for ({}0;){}}0;){}for (X:{}0;){}cast(e)q{u}w~r"o"w; ``` Yes, there are cases of parser footguns that are prevented by the compiler, such as a lambda returning a function literal `() => {}`. Such exceptions should not be the norm though, and this issue's particular case is so minor that I don't think it's worth the added complexity. Consider how there's also (minor) second order effects, like how this change could break a D minification tool. D-scanner would be the right place to implement such a check: https://github.com/dlang-community/D-Scanner -- |
June 22, 2023 [Issue 23999] literal suffixes dont mix well with template instantiations | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=23999 --- Comment #10 from Puneet Goel <puneet@coverify.org> --- I think it is a bug (or maybe I should call it unexpected compiler behavior) at a more fundamental level. Consider how both clang and gcc treat literal suffix errors differently compared to Dlang: $ cat /tmp/test.d ulong test = 44LUNG; $ ldc2 /tmp/test.d /tmp/test.d(1): Error: semicolon expected following auto declaration, not `NG` /tmp/test.d(1): Error: no identifier for declarator `NG` $ cat /tmp/test.c int long unsigned test = 44LUNG; $ gcc /tmp/test.c /tmp/test.c:1:26: error: invalid suffix "LUNG" on integer constant 1 | int long unsigned test = 44LUNG; | ^~~~~~ $ clang /tmp/test.c /tmp/test.c:1:28: error: invalid suffix 'LUNG' on integer constant int long unsigned test = 44LUNG; ^ 1 error generated. -- |
June 22, 2023 [Issue 23999] literal suffixes dont mix well with template instantiations | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=23999 --- Comment #11 from Puneet Goel <puneet@coverify.org> --- Should I reopen this error, or file another bug for unexpected/wrong literal suffix parsing? -- |
June 22, 2023 [Issue 23999] literal suffixes dont mix well with template instantiations | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=23999 mhh <maxhaton@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |maxhaton@gmail.com --- Comment #12 from mhh <maxhaton@gmail.com> --- Why is this impossible to express? You can write a new rule to match it and then mark it illegal if nothing else. (That and the grammar is not the whole). I think it's worth banning this, C does for example. -- |
March 21 [Issue 23999] literal suffixes dont mix well with template instantiations | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=23999 Walter Bright <bugzilla@digitalmars.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |bugzilla@digitalmars.com --- Comment #13 from Walter Bright <bugzilla@digitalmars.com> --- Interestingly, ImportC sez: test.c(1): Error: missing comma or semicolon after declaration of `test`, found `NG` instead -- |
Copyright © 1999-2021 by the D Language Foundation