foo.bar !in baz not allowed?
For some reason, it seems like expressions of the form foo.bar !in baz aren't allowed. I suspect this is a grammar/parser problem -- the bang is interpreted as a template argument operator, rather than a negation operator, and there's really no need to make that interpretation when it is immediately followed by in. This suspicion is strengthened by the fact that bar !in baz is fine, as is (foo.bar) !in baz. Should I file this as a bug? Small sample program: struct Foo { uint bar; } struct Baz { bool opIn_r(uint e) { return false; } } void main() { Baz baz; Foo foo; auto res = (foo.bar) !in baz; res = !(foo.bar in baz); // res = foo.bar !in baz; // Not OK... uint frozz; res = frozz !in baz; } -- Magnus Lie Hetland http://hetland.org
Re: foo.bar !in baz not allowed?
On 03/13/2011 07:58 PM, Magnus Lie Hetland wrote: For some reason, it seems like expressions of the form foo.bar !in baz aren't allowed. I suspect this is a grammar/parser problem -- the bang is interpreted as a template argument operator, rather than a negation operator, and there's really no need to make that interpretation when it is immediately followed by in. This suspicion is strengthened by the fact that bar !in baz is fine, as is (foo.bar) !in baz. Should I file this as a bug? Small sample program: struct Foo { uint bar; } struct Baz { bool opIn_r(uint e) { return false; } } void main() { Baz baz; Foo foo; auto res = (foo.bar) !in baz; res = !(foo.bar in baz); // res = foo.bar !in baz; // Not OK... uint frozz; res = frozz !in baz; } Would be nice to copy the error, wouldn't it? template argument expected following ! Anyway, this is definitely a bug in my opinion. Denis -- _ vita es estrany spir.wikidot.com
Re: foo.bar !in baz not allowed?
On 2011-03-13 21:27:27 +0100, spir said: On 03/13/2011 07:58 PM, Magnus Lie Hetland wrote: For some reason, it seems like expressions of the form foo.bar !in baz aren't allowed. I suspect this is a grammar/parser problem -- the bang is interpreted as a template argument operator, rather than a negation operator, [snip] Would be nice to copy the error, wouldn't it? template argument expected following ! Ah. I thought my explanation (see above) made that clear. Anyway, this is definitely a bug in my opinion. Turns out it's an old one. Sorry about that: http://d.puremagic.com/issues/show_bug.cgi?id=4159 -- Magnus Lie Hetland http://hetland.org