D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 4137 - Undefined identifier error in is(typeof())
Summary: Undefined identifier error in is(typeof())
Status: RESOLVED INVALID
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86 Windows
: P2 normal
Assignee: No Owner
URL:
Keywords: diagnostic
Depends on:
Blocks:
 
Reported: 2010-05-01 05:38 UTC by bearophile_hugs
Modified: 2015-06-09 05:14 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-05-01 05:38:35 UTC
I don't know if there are ways to solve this problem, I hope this isn't another situation like bug 3950.

This is wrong D2 code. The template Foo has the type parameter T while inside it uses the parameter R:


template Foo(T) {
    enum bool Foo = is(typeof(R.length));
}
void main() {
    assert(Foo!(int[]));
}


The program compiles with no errors with dmd 2.043 and at run time produces:
core.exception.AssertError@test2(5): Assertion failure

But to help debugging, I'd like the compiler to point R as a undefined identifier (even with the 'did you mean...') at compile-time. Is this possible?
Comment 1 Walter Bright 2010-05-01 09:45:29 UTC
This is expected & documented behavior. Compilation failures inside "is" expressions cause the is expression result to be false. A lot of template code relies on this.

If you want an error on R being undefined, use it somewhere else in addition to inside the "is" expression.