Bug 11614 – Error: this for _expand_field_0 needs to be type Tuple not type Foo

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-11-26T23:46:00Z
Last change time
2013-11-30T12:28:24Z
Keywords
pull, rejects-valid
Assigned to
nobody
Creator
doob

Comments

Comment #0 by doob — 2013-11-26T23:46:39Z
The following code used to compile with DMD 2.063.2: import std.typecons; struct Foo { alias Tuple!(int) NEW_ARGS; NEW_ARGS args; void foo () { static if (NEW_ARGS.length == 1) {} } } But compiling the above code with DMD 2.064.2 results in this error: typecons.d(389): Error: this for _expand_field_0 needs to be type Tuple not type Foo Am I doing something wrong or is this a regression? If I do any of the following the code will compile: * Move the static-if outside of "foo" * Replace "NEW_ARGS.length" with "args.length" in the static-if
Comment #1 by k.hara.pg — 2013-11-28T19:43:15Z
Comment #2 by github-bugzilla — 2013-11-30T12:25:16Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/c2ba89dc203c34740fbc21d8a116994046a7bbf4 fix Issue 11614 - Error: this for _expand_field_0 needs to be type Tuple not type Foo Even if a variable has no valid context, it would be either: 1. a part of compile time evaluated expression, which is used as unreal context. enum x = Type.fieldvar.sizeof; // It's legitimate expression so fieldvar is not evaluated // in runtime. 2. or an invalid field access without valid 'this', in runtime evaluated expression. int y = Type.fieldvar; // It's invalid expression so fieldvar access has no valid 'this'. For the case #2, it will be an error by `checkRightThis` later. Therefore `getRightThis` should not make it an error. https://github.com/D-Programming-Language/dmd/commit/4d994d640f32a50e3bfb84c5e99118c7a057cce4 Merge pull request #2897 from 9rnsr/fix11614 [REG2.064] Issue 11614 - Error: this for _expand_field_0 needs to be type Tuple not type Foo