digitalmars.D.bugs - [Issue 3955] New: Very poor error message: accidentally assigning to string literal in template
- d-bugmail puremagic.com (44/44) Mar 13 2010 http://d.puremagic.com/issues/show_bug.cgi?id=3955
- d-bugmail puremagic.com (12/12) Feb 12 2011 http://d.puremagic.com/issues/show_bug.cgi?id=3955
http://d.puremagic.com/issues/show_bug.cgi?id=3955 Summary: Very poor error message: accidentally assigning to string literal in template Product: D Version: 1.056 Platform: All OS/Version: All Status: NEW Keywords: diagnostic Severity: normal Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: matti.niemenmaa+dbugzilla iki.fi 2010-03-13 08:34:35 PST --- For the following code: template T(char[] s) { static if (s[0] = 'f') // error here; line 2 const T = ""; else const T = "" ~ T!(s); } const char[] A = T!("foo"); // line 8 const char[] B = "" ~ A; DMD 1.056 emits: $ dmd -c arst.d arst.d(8): Error: cannot implicitly convert expression (__error ~ __error) of type int to char[] Which is about as obtuse as possible: - __error looks like something that should only show up when debugging the compiler. It's certainly not to be found anywhere in the source. - There is no ~ on line 8: the message points only to the use of T, not the actual problem which is within T. - DMD's usual habit of using "int" when it hits any kind of error. Removing the apparently unrelated constant B from line 9, we get the following message that actually indicates the problem. This is what I'd expect to get regardless of B: $ dmd -c arst.d arst.d(2): Error: string literals are immutable arst.d(2): Error: expression 'f' = 'f' is not constant or does not evaluate to a bool -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 13 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3955 Don <clugdbug yahoo.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |clugdbug yahoo.com.au Resolution| |FIXED Fixed DMD 1.061. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 12 2011