Bug 4544 – Better error-message when expecting string but got a character constant
Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
Windows
Creation time
2010-08-01T07:01:28Z
Last change time
2019-11-23T19:32:40Z
Keywords
bootcamp, pull
Assigned to
No Owner
Creator
Andrej Mitrovic
Comments
Comment #0 by andrej.mitrovich — 2010-08-01T07:01:28Z
In this example single quotes were used instead of double quotes by accident:
import std.stdio;
void main() {
writeln('test');
}
This spits out way too many error lines:
test.d(5): unterminated character constant
test.d(5): found 'est' when expecting ','
test.d(5): unterminated character constant
test.d(5): found ';' when expecting ','
test.d(6): expression expected, not '}'
test.d(7): found 'EOF' when expecting ','
test.d(7): expression expected, not 'EOF'
test.d(7): found 'EOF' when expecting ','
test.d(7): expression expected, not 'EOF'
test.d(7): found 'EOF' when expecting ','
test.d(7): expression expected, not 'EOF'
test.d(7): found 'EOF' when expecting ','
test.d(7): expression expected, not 'EOF'
test.d(7): found 'EOF' when expecting ','
test.d(7): expression expected, not 'EOF'
test.d(7): found 'EOF' when expecting ','
test.d(7): expression expected, not 'EOF'
test.d(7): found 'EOF' when expecting ','
test.d(7): expression expected, not 'EOF'
test.d(7): found 'EOF' when expecting ','
test.d(7): expression expected, not 'EOF'
I'm hoping for a simpler error message than all of this. :)
Comment #1 by andrej.mitrovich — 2010-08-01T10:49:25Z
I'm sorry, I meant "literal", not constant.
Comment #2 by lt.infiltrator — 2015-10-31T14:37:39Z
Still exists in 2.068.
Comment #3 by dmitry.olsh — 2018-05-17T16:34:16Z
A tiny bit better but still godawful on v2.080:
saa.d(5): Error: unterminated character constant
saa.d(5): Error: found est when expecting ,
saa.d(5): Error: unterminated character constant
saa.d(5): Error: found ; when expecting ,
saa.d(6): Error: expression expected, not }
saa.d(6): Error: found EOF when expecting ,
saa.d(6): Error: found EOF when expecting )
saa.d(6): Error: found EOF when expecting ; following statement
saa.d(6): Error: found EOF when expecting } following compound statement
Comment #4 by dlang-bot — 2019-11-13T16:38:12Z
@alexandrumc created dlang/dmd pull request #10569 "Fix Issue 4544 - Better error-message when expecting string but got a character constant" fixing this issue:
- Fix Issue 4544 - Better error-message when expecting string but got a character constant
https://github.com/dlang/dmd/pull/10569
Comment #5 by dlang-bot — 2019-11-23T19:32:40Z
dlang/dmd pull request #10569 "Fix Issue 4544 - Better error-message when expecting string but got a character constant" was merged into master:
- dd74f6ee95e4f19da7d55c196b06eaa1de7ea94d by Alexandru Militaru:
Fix Issue 4544 - Better error-message when expecting string but got a character constant
https://github.com/dlang/dmd/pull/10569