Bug 3013 – Duplicate error message on calling a function with a type

Status
RESOLVED
Resolution
FIXED
Severity
trivial
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2009-05-20T06:19:00Z
Last change time
2013-11-16T21:14:37Z
Keywords
diagnostic, pull
Assigned to
nobody
Creator
davidl

Comments

Comment #0 by davidl — 2009-05-20T06:19:09Z
import std.string; void main() { char[] s= string.format("abc","abc"); } testd.d(5): Error: cannot implicitly convert expression (format((& D20TypeInfo_B9AyaAyaAya6__initZ),(immutable(char)[]), "abc","abc")) of type immutable(char)[] to char[]
Comment #1 by rinick — 2009-05-20T08:21:34Z
string.format("abc","abc"); is same as format(string, "abc", "abc"); which means: format(immutable(char)[], "abc", "abc");
Comment #2 by davidl — 2009-05-20T19:21:02Z
The point is the error message should not expose mangled name to users. The original title is pretty clear.
Comment #3 by davidl — 2009-05-20T19:22:28Z
err , it was unclear.. there was a typo.
Comment #4 by smjg — 2009-05-21T17:20:05Z
(In reply to comment #1) > string.format("abc","abc"); > is same as > format(string, "abc", "abc"); > which means: > format(immutable(char)[], "abc", "abc"); I'm confused. Since when has it been legal to pass a type as a function argument?
Comment #5 by rinick — 2009-05-21T18:37:25Z
(In reply to comment #4) > (In reply to comment #1) > > string.format("abc","abc"); > > is same as > > format(string, "abc", "abc"); > > which means: > > format(immutable(char)[], "abc", "abc"); > > I'm confused. Since when has it been legal to pass a type as a function > argument? It's not legal. I was just explaining the error message of this bug: > import std.string; > > void main() > { > char[] s= string.format("abc","abc"); > } > > testd.d(5): Error: cannot implicitly convert expression (format((& > D20TypeInfo_B9AyaAyaAya6__initZ),(immutable(char)[]), > "abc","abc")) of type immutable(char)[] to char[]
Comment #6 by smjg — 2009-05-22T02:53:48Z
So the bug is that it tries to make out the type of the expression and gets somewhere (and hence delivers an error) before realising that string.format is itself invalid. The bug also occurs in DMD 1.043, as this shows: ---------- import std.string; void main() { int s = string.format("abc", "def"); } ---------- array_static_method.d(4): Error: cannot implicitly convert expression (format((& D17TypeInfo_B6AaAaAa6__initZ),(char[]),"abc","def")) of type char[] to int ---------- Strangely, given (int[]) instead of string, 2.030 gives an almost identical cryptic message, but 1.043 emits the more sensible ---------- array_static_method.d(4): Error: no property 'format' for type 'int[]' array_static_method.d(4): Error: function expected before (), not 1 of type int ---------- (OK, so the second message is bogus, but that's just a case of a long-known issue.)
Comment #7 by yebblies — 2013-11-16T19:38:36Z
Currently prints: DMD v2.065 DEBUG testx.d(4): Error: string is not an expression testx.d(4): Error: string is not an expression testx.d(4): Error: cannot pass type string as function argument Which is pretty accurate except for the duplicate errors. https://github.com/D-Programming-Language/dmd/pull/2786
Comment #8 by github-bugzilla — 2013-11-16T21:09:12Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/7e59edf65460423ea93d1c1ee04928f26e1b82b8 Fix Issue 3013 - Duplicate error message on calling a function with a type https://github.com/D-Programming-Language/dmd/commit/4f4901d782e8d3dc6ccce151e013d953b3b21963 Merge pull request #2786 from yebblies/issue3013 Issue 3013 - Duplicate error message on calling a function with a type