Bug 8417 – Better error message on invalid operator call

Status
RESOLVED
Resolution
WORKSFORME
Severity
enhancement
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-07-22T15:09:00Z
Last change time
2014-03-24T10:35:08Z
Assigned to
nobody
Creator
andrej.mitrovich

Comments

Comment #0 by andrej.mitrovich — 2012-07-22T15:09:50Z
import std.getopt; void main(string[] args) { string foo; getopt(args, "foo" &foo ); } Notice that a comma is missing after "foo". The errors leak into getopt: bug_new.d(19): Error: '"foo"' is not of integral type, it is a string bug_new.d(19): Error: 'foo' is not of integral type, it is a string D:\DMD\dmd2\windows\bin\..\..\src\phobos\std\getopt.d(386): Error: array index [1] is outside array bounds [0 .. 1] D:\DMD\dmd2\windows\bin\..\..\src\phobos\std\getopt.d(508): Error: using * on an array is deprecated; use *(receiver).ptr instead D:\DMD\dmd2\windows\bin\..\..\src\phobos\std\getopt.d(513): Error: using * on an array is deprecated; use *(receiver).ptr instead D:\DMD\dmd2\windows\bin\..\..\src\phobos\std\getopt.d(524): Error: static assert "Dunno how to deal with type string" D:\DMD\dmd2\windows\bin\..\..\src\phobos\std\getopt.d(394): instantiated from here: handleOption!(string) D:\DMD\dmd2\windows\bin\..\..\src\phobos\std\getopt.d(345): instantiated from here: getoptImpl!(string) bug_new.d(18): instantiated from here: getopt!(string) Failed: "dmd" "-unittest" "-w" "-J." "-v" "-o-" "bug_new.d" "-I." >Exit code: 1
Comment #1 by andrej.mitrovich — 2014-03-24T10:35:08Z
In 2.065 the diagnostic no longer leaks into std.getopt: test.d(7): Error: invalid array operation "foo" & foo (did you forget a [] ?)