D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 4715 - Bad error message with update for already defined variable
Summary: Bad error message with update for already defined variable
Status: RESOLVED INVALID
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 minor
Assignee: No Owner
URL:
Keywords: diagnostic
Depends on:
Blocks:
 
Reported: 2010-08-22 19:48 UTC by bearophile_hugs
Modified: 2013-11-16 23:06 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description bearophile_hugs 2010-08-22 19:48:41 UTC
This wrong D2 program:

void main() {
    int foo = 1;
    int foo = 1;
}


Produces a good error message (dmd 2.048):
test.d(3): Error: declaration test.main.foo is already defined


But this similar wrong program:

void main() {
    int foo = 1;
    int foo -= 1;
}


Produces two wrong error messages:
test.d(3): semicolon expected, not '-='
test.d(3): found '-=' instead of statement


I'd like this second situation to generate the same error as before.
Comment 1 yebblies 2013-11-16 23:06:52 UTC
The second case has a syntax error, and doesn't get through parsing.  There is no way to get semantic errors if it won't parse.