4270 – Missing line number in 'can only catch class objects' error message

D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 4270 - Missing line number in 'can only catch class objects' error message
Summary: Missing line number in 'can only catch class objects' error message
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: Other Windows
: P2 normal
Assignee: No Owner
URL:
Keywords: diagnostic, patch
Depends on:
Blocks:
Reported: 2010年06月04日 12:51 UTC by Don
Modified: 2014年02月15日 02:43 UTC (History)
2 users (show)

See Also:


Attachments
Add an attachment (proposed patch, testcase, etc.)

Note You need to log in before you can comment on or make changes to this issue.
Description Don 2010年06月04日 12:51:32 UTC
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 Don 2010年06月04日 13:15:49 UTC
Bug 3712 is a combination of this bug, with a D1-only error.
Comment 2 bearophile_hugs 2010年06月04日 13:20:59 UTC
An idea: comment out the error() that doesn't accept a line number, then fix all calling points that use it.
Comment 3 Don 2010年06月04日 17:36:00 UTC
(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.
Comment 4 Walter Bright 2010年06月09日 19:09:30 UTC
http://www.dsource.org/projects/dmd/changeset/532 


AltStyle によって変換されたページ (->オリジナル) /