mirror of
https://github.com/dlang/dmd.git
synced 2025-04-26 21:21:48 +03:00

For a long time, the 'in' storage class was only a second class citizen, merely an alias for 'const', which is a type constructor. While it was also documented for a long time as being 'scope', this was removed when 'scope' actually started to have an effect (when DIP1000 started to be implemented). Currently, a switch (-preview=in) allows to get back this 'scope'. However, the 'in' storage class does not really exists, it gets lowered to 'const [scope]' at an early stage by the compiler, which means that we expose what is essentially an implementation detail to the user. This led to a variety of problems for both developers and users. The most obvious one was that functions involving `in` would show up simply as `const` (or `const scope`), both in generated header and error messagges, hindering the ability to do header generation with `-preview=in` as the same value for this switch was needed for both producer and consumer. Another issue was that the result of `__traits(getParameterStorageClass)` was inaccurate, giving either an empty tuple or `scope`. Lastly, the lack of mangling for `in` means that stack trace would show the wrong signature for a function, potentially confusing the users. For compiler developers, the `in` storage class simply couldn't be relied on, as it was replaced by `const [scope]` rather early in the semantic phase (in TypeFunction's semantic), which lead to some dead code (e.g. in dmangle). After this change, the class will show up properly in error message, and in `getParameterStorageClass`, which can be a surprising change for users. However, it is not expected that code can break as a result, unless they break as a result of using the `-preview=in` switch.
11 lines
654 B
Text
11 lines
654 B
Text
Parameters marked as `in` will now be properly displayed
|
|
|
|
In earlier releases, using `in` on parameters would be lowered too early,
|
|
leading to confusing display: error messages would show the parameter
|
|
as `const` (or `scope const` if `-preview=in` was used),
|
|
and so would header generations or stack traces.
|
|
The header generation was problematic, as a header generated with `-preview=in`
|
|
would be different from one generated without.
|
|
From this release, `in` will now display correctly in every message.
|
|
As this requires an update to the mangling, some older debuggers or tools
|
|
might not be able to properly demangle functions that uses `in` parameters.
|