Thread overview | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
November 13, 2023 [Issue 24241] Uncaught Default argument error | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=24241 --- Comment #1 from ponce <aliloko@gmail.com> --- Created attachment 1900 --> https://issues.dlang.org/attachment.cgi?id=1900&action=edit Repro screenshot -- |
November 13, 2023 [Issue 24241] Uncaught Default argument error | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=24241 Basile-z <b2.temp@gmx.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |b2.temp@gmx.com --- Comment #2 from Basile-z <b2.temp@gmx.com> --- That does not compile if called without the second arg however lookup_decoding(1); I suppose this bug is related to named arg handling ? -- |
November 13, 2023 [Issue 24241] Uncaught Default argument error | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=24241 --- Comment #3 from Basile-z <b2.temp@gmx.com> --- hence that would not be a bug after all ? -- |
November 13, 2023 [Issue 24241] Uncaught Default argument error | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=24241 --- Comment #4 from ponce <aliloko@gmail.com> --- Oh this is a voluntary change? In practice, what we've had is that code that is produced by people after that change, break build of those that use earlier compilers. It's a breaking change that I feel we could warn about, since it seems named arguments aren't already there? -- |
November 13, 2023 [Issue 24241] Uncaught Default argument error | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=24241 --- Comment #5 from ponce <aliloko@gmail.com> --- It used to be illegal to have default values for arguments not at the end, making this legal is unexpected (and creates issues like this). -- |
November 13, 2023 [Issue 24241] Uncaught Default argument error | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=24241 --- Comment #6 from ponce <aliloko@gmail.com> --- By spec: https://dlang.org/spec/function.html#function-default-args > Default parameters are resolved and semantically checked in the context of the function declaration. and later > If the default value for a parameter is given, all following parameters must also have default values. Pretty much a bug then? -- |
November 13, 2023 [Issue 24241] Uncaught Default argument error | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=24241 RazvanN <razvan.nitu1305@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |razvan.nitu1305@gmail.com --- Comment #7 from RazvanN <razvan.nitu1305@gmail.com> --- Yes, this is an intended change as per the named arguments dip: https://github.com/dlang/DIPs/blob/15537f9b36afa48f1c1cd57468e8c77f8f2499dd/DIPs/DIP1030.md . I don't see how this change breaks any existing code. Old code works as it used to work under the newer compiler versions, whereas new code may be written to take advantage of named parameters. The situation that was invoked: "In practice, what we've had is that code that is produced by people after that change, break build of those that use earlier compilers." is true for any other compiler addition. If a library writer uses the newest fanciest features, then it is expected that the users of the said library need to use newer versions of the compiler. > It's a breaking change that I feel we could warn about, since it seems named arguments aren't already there? How would a warning help here since the code is not going to compile anyway? I don't really see anything actionable for this bug report. -- |
November 13, 2023 [Issue 24241] Uncaught Default argument error | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=24241 --- Comment #8 from RazvanN <razvan.nitu1305@gmail.com> --- (In reply to ponce from comment #6) > By spec: https://dlang.org/spec/function.html#function-default-args > > > > Default parameters are resolved and semantically checked in the context of the function declaration. > > and later > > > If the default value for a parameter is given, all following parameters must also have default values. > > > Pretty much a bug then? The spec needs to be updated. -- |
November 13, 2023 [Issue 24241] Uncaught Default argument error | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=24241 --- Comment #9 from Basile-z <b2.temp@gmx.com> --- sorry about my previous comments, they were more about the general semantics of "default arguments" but you're right, D specs are the reference here. -- |
November 13, 2023 [Issue 24241] Uncaught Default argument error | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=24241 --- Comment #10 from ponce <aliloko@gmail.com> --- It's surprising to me because it seems nothing hints at this rule changing (not even in spec). The new rules are cool and all, and it's easy to see named arguments will hugely improve readability. It's just that if you're not aware of them changing because following D from even a tiny distance, you can miss the changes completely. Are there other changes like this? How can I get up to speed? Under the release changelog, I'm struggling to find a point where this has changed ("if you write code in the new way, then it's breaking old compilers") can be seen. -- |
Copyright © 1999-2021 by the D Language Foundation