Thread overview | |||||||||
---|---|---|---|---|---|---|---|---|---|
|
July 06, 2023 [Issue 24032] Compiler is parsing string parameters to Templates | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=24032 FeepingCreature <default_357-line@yahoo.de> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |default_357-line@yahoo.de --- Comment #1 from FeepingCreature <default_357-line@yahoo.de> --- Yes, Q{} is defined in the grammar as a "token string" which must consist of valid D tokens, because it's meant to pass around fragments of source code. "0X" stopped being a valid token in DMD 2.084.0: https://dlang.org/changelog/2.084.0.html#deprecated_binary_literals -- |
July 06, 2023 [Issue 24032] Compiler is parsing string parameters to Templates | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=24032 --- Comment #2 from FeepingCreature <default_357-line@yahoo.de> --- If you can replace the string with `q{0x0}`, that should work. Alternately, pass a regular `"0x"` string. -- |
July 06, 2023 [Issue 24032] Compiler is parsing string parameters to Templates | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=24032 --- Comment #3 from Puneet Goel <puneet@coverify.org> --- I am using q{} to write my own DSL. For this particular thing, I need to extend binary number strings in a way where I can write stuff like 0b?01?11 where '?' can be used for pattern matching. So, this becomes blocking for me. Is there an easy solution, or do I need to discover an alternate syntax for my need? BTW, what advantage do we gain by making the compiler parse q{} as a token string? -- |
July 06, 2023 [Issue 24032] Compiler is parsing string parameters to Templates | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=24032 --- Comment #4 from Puneet Goel <puneet@coverify.org> --- Even if we have to do token parsing for q{}, the following code should not fail. class Foo(string str) {} void main() { Foo!q{string str = "0X"} foo; Foo!q{string str = "0B"} bar; } The compiler gives the same errors as it gives for q{0B} and q{0X}. -- |
July 06, 2023 [Issue 24032] Compiler is parsing string parameters to Templates | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=24032 --- Comment #5 from Puneet Goel <puneet@coverify.org> --- Please ignore the previous comment. There was a mistake at my end. -- |
July 06, 2023 [Issue 24032] Compiler is parsing string parameters to Templates | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=24032 --- Comment #6 from FeepingCreature <default_357-line@yahoo.de> --- The easy solution would be writing `foo!"0b?01?11"`. `q{}` is intended for fragments of D code. -- |
July 10, 2023 [Issue 24032] Compiler is parsing string parameters to Templates | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=24032 Dennis <dkorpel@live.nl> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |dkorpel@live.nl Hardware|x86_64 |All Resolution|--- |INVALID OS|Linux |All --- Comment #7 from Dennis <dkorpel@live.nl> --- Like FeepingCreature said, q{} is a string of D tokens, typically used for string mixin purposes. dmd's behavior is correct. Please use a different string literal kind for strings with code from other languages. -- |
Copyright © 1999-2021 by the D Language Foundation