Bug 4270 – Missing line number in 'can only catch class objects' error message
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
Windows
Creation time
2010-06-04T12:51:00Z
Last change time
2014-02-15T02:43:07Z
Keywords
diagnostic, patch
Assigned to
nobody
Creator
clugdbug
Comments
Comment #0 by clugdbug — 2010-06-04T12:51:32Z
void bug4270()
{
try{} catch(int banana) {}
}
--
Error: can only catch class objects, not 'int'
--
PATCH:
statement.c 4197
void Catch::semantic(Scope *sc)
type = type->semantic(loc, sc);
if (!type->toBasetype()->isClassHandle())
- error("can only catch class objects, not '%s'", type->toChars());
+ error(loc, "can only catch class objects, not '%s'", type->toChars());
Comment #1 by clugdbug — 2010-06-04T13:15:49Z
Bug 3712 is a combination of this bug, with a D1-only error.
Comment #2 by bearophile_hugs — 2010-06-04T13:20:59Z
An idea: comment out the error() that doesn't accept a line number, then fix all calling points that use it.
Comment #3 by clugdbug — 2010-06-04T17:36:00Z
(In reply to comment #2)
> An idea: comment out the error() that doesn't accept a line number, then fix
> all calling points that use it.
That's exactly how I found this one! There are four uses of the wrong function. It's discussed in dmd-internals.