Thread overview | ||||||||
---|---|---|---|---|---|---|---|---|
|
November 04, 2010 [Issue 5163] New: meaningless error message with front() applied to void[] | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=5163 Summary: meaningless error message with front() applied to void[] Product: D Version: D2 Platform: All OS/Version: All Status: NEW Keywords: diagnostic, rejects-valid Severity: normal Priority: P2 Component: DMD AssignedTo: nobody@puremagic.com ReportedBy: mrmocool@gmx.de --- Comment #0 from Trass3r <mrmocool@gmx.de> 2010-11-04 08:08:33 PDT --- import std.array; void main() { void[] a = cast(void[]) [ 1, 2, 3 ]; a.front; } yields: ..\src\phobos\std\array.d(419): Error: [i] has no effect in expression (a[0u]) ..\src\phobos\std\array.d(5): Error: template instance std.array.front!(void[]) error instantiating Originally I used std.file.read(), hence the void array. - 1st message is completely senseless, what "[i]"? - 2nd message shows line 5 which is the line of "a.front;" but the filename is wrong. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
November 05, 2010 [Issue 5163] meaningless error message with front() applied to void[] | ||||
---|---|---|---|---|
| ||||
Posted in reply to Trass3r | http://d.puremagic.com/issues/show_bug.cgi?id=5163 Lars T. Kyllingstad <bugzilla@kyllingen.net> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |bugzilla@kyllingen.net Component|DMD |Phobos --- Comment #1 from Lars T. Kyllingstad <bugzilla@kyllingen.net> 2010-11-05 04:38:32 PDT --- This is actually two separate issues. The first is a Phobos issue, namely that there should be a template constraint on std.array.front() that prevents it from being instantiated on void[] arrays. front() is defined as something like T front(T)(T[] array) { return array[0]; } You cannot index into a void[] array, hence the first error message. This also means that void[] cannot be a range. The second is the issue of the wrong line number, which is a bug in DMD. I'm guessing it's just bug 1913 again, so I'm marking this one as a Phobos issue. In the case of a void[] returned from std.file.read(), you need to cast it to ubyte[] before using it as a range. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
November 05, 2010 [Issue 5163] meaningless error message with front() applied to void[] | ||||
---|---|---|---|---|
| ||||
Posted in reply to Trass3r | http://d.puremagic.com/issues/show_bug.cgi?id=5163 Lars T. Kyllingstad <bugzilla@kyllingen.net> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |FIXED --- Comment #2 from Lars T. Kyllingstad <bugzilla@kyllingen.net> 2010-11-05 05:18:35 PDT --- This fixes the Phobos bug: http://www.dsource.org/projects/phobos/changeset/2123 The error message is now: test.d(6): Error: template std.array.front(A) if (is(typeof(A[0])) && !isNarrowString!(A) && !is(typeof(A[0]) : const(void))) does not match any function template declaration test.d(6): Error: template std.array.front(A) if (is(typeof(A[0])) && !isNarrowString!(A) && !is(typeof(A[0]) : const(void))) cannot deduce template function from argument types !()(void[]) Arguably less readable, but more useful since it refers to the point of error in user code instead of in Phobos code. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
November 05, 2010 [Issue 5163] meaningless error message with front() applied to void[] | ||||
---|---|---|---|---|
| ||||
Posted in reply to Trass3r | http://d.puremagic.com/issues/show_bug.cgi?id=5163 bearophile_hugs@eml.cc changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |bearophile_hugs@eml.cc --- Comment #3 from bearophile_hugs@eml.cc 2010-11-05 05:36:36 PDT --- (In reply to comment #2) > Arguably less readable, but more useful since it refers to the point of error in user code instead of in Phobos code. Too bad there is no handy way to add error messages to template constraints... -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
November 05, 2010 [Issue 5163] meaningless error message with front() applied to void[] | ||||
---|---|---|---|---|
| ||||
Posted in reply to Trass3r | http://d.puremagic.com/issues/show_bug.cgi?id=5163 --- Comment #4 from Trass3r <mrmocool@gmx.de> 2010-11-05 09:37:28 PDT --- Thx for the fix, but I still think that strange [i] in the error message is a diagnostic bug, reopen it? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
November 08, 2010 [Issue 5163] meaningless error message with front() applied to void[] | ||||
---|---|---|---|---|
| ||||
Posted in reply to Trass3r | http://d.puremagic.com/issues/show_bug.cgi?id=5163 Lars T. Kyllingstad <bugzilla@kyllingen.net> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords|rejects-valid | --- Comment #5 from Lars T. Kyllingstad <bugzilla@kyllingen.net> 2010-11-08 02:26:24 PST --- I think '[i]' is just a compact way of saying 'indexing operation'. I guess it could just as well have been '[#]', '[index]', or whatever. (Even better would be a message saying that you can't index into void[] arrays.) Anyway, I suggest you open a new bug report about it. It's better not to have two bugs in one report -- especially when one is a Phobos bug and the other is a DMD bug. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation