Fix invalid characters in mangling#7531
Conversation
|
Thanks for your pull request and interest in making D better, @jacob-carlborg! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please see CONTRIBUTING.md for more information. If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment. Bugzilla references
Testing this PR locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub fetch digger
dub run digger -- build "master + dmd#7531" |
|
CIs are failing with: Also mind the |
|
This is a regression fix, and so should have a bugzilla entry for it. |
|
I looked at one of the failing tests in Phobos. The test inspects the demangle of a symbol. Before this PR the mangled name was I did what @ibuclaw suggested on Slack and took the validation that is performed on |
|
I would restrain from putting any special character into the mangling as this will byte you back later. For example So, The validation in dmangle is not strict enough for most D symbols and too strict for symbols in general, as any characters can creep into the mangled string as part of a template alias parameter. |
|
@rainers so perhaps we shouldn't use the exact same validation everywhere. Because with |
|
Yes, I support the comment in dymbolsem.d: "Ideally pragma(mangle) can accept a string of any content." |
|
I would expect |
|
Yes, core.demangle doesn't work for the plain symbol set by pragma(mangle), but should be able to handle "embedded" symbols, i.e. as template alias parameters. That means it skips them correctly while decoding the rest. |
|
So what kind of validation would we like to have in the case of unittest blocks? |
Not sure it needs any validation, because I don't think the filename is a good identifier to begin with. It might contain relative or absolute path components which makes it rather unpredictable. I'd recommend using the module name instead. If you want to replace the dots with an underscore and disambiguate with a module name already containing the underscore, use the mangling scheme for the module name, e.g. Long term I think all those internal identifiers should follow the normal naming scheme, e.g. |
31b08eb to
a81e139
Compare
|
Rebased and interestingly modifying the test was no longer required. |
The tests are still not passing. I think Atila's PR #7761 will fix this as well. But this might be good to have anyway. |
a81e139 to
d08ed57
Compare
src/dmd/func.d
Outdated
| import dmd.declaration; | ||
| import dmd.delegatize; | ||
| import dmd.dinterpret; | ||
| import dmd.dmangle; |
There was a problem hiding this comment.
Indeed. Most likely the original patch had the semantic pass in this module. Now it's been moved to dsymbolsem.
|
Why is this still open? Valid code doesn't assemble because of this. |
d08ed57 to
ad25e05
Compare
Running the DMD test suite with a compiler compiled in debug mode fails due to invalid characters, `-`, exist in the mangled names of some unittest blocks. This fix centralizes the validation of mangled characters and properly replaces `-` in the mangled names of unittest blocks with `_`.
ad25e05 to
9d08623
Compare
Because it was failing on auto-tester for a long time and then was having merge conflicts. |
Running the DMD test suite with a compiler compiled in debug mode fails due to invalid characters,
-, exist in the mangled names of some unittest blocks.This fix centralizes the validation of mangled characters and properly replaces
-in the mangled names of unittest blocks with_.The issue was introduced in #6727.