Bug 5785 – Lexing or Parsing issue with UFCS

Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
Windows
Creation time
2011-03-25T16:01:00Z
Last change time
2011-08-12T12:54:49Z
Keywords
patch, rejects-valid
Assigned to
nobody
Creator
andrej.mitrovich

Comments

Comment #0 by andrej.mitrovich — 2011-03-25T16:01:57Z
import std.stdio; import std.file; import std.path; int[string] fileExtensions; void main() { string filename; if (!filename.isFile || filename.getExt !in fileExtensions) { } } > test.d(13): template argument expected following ! The way around this is to not use UFCS: if (!filename.isFile || getExt(filename) !in fileExtensions) which is a damn shame because UFCS is a great thing to have.
Comment #1 by andrej.mitrovich — 2011-03-25T16:04:15Z
Note that `is` _can_ be used, but `!is` cannot. Hence: This builds fine: if (!filename.isFile || filename.getExt in fileExtensions) This doesn't: if (!filename.isFile || filename.getExt !in fileExtensions)
Comment #2 by kennytm — 2011-03-25T16:23:18Z
Workaround: if (!filename.isFile || (filename.getExt) !in fileExtensions) ----
Comment #3 by r.sagitario — 2011-03-26T01:20:53Z
I think !is and !in should be single tokens. Right now, you can write spaces and comments between ! and is/in.
Comment #4 by r.sagitario — 2011-04-08T00:17:27Z
Here is a patch that allows to deal with this without creating new tokens: diff --git a/src/parse.c b/src/parse.c index 162fa85..199cf89 100644 --- a/src/parse.c +++ b/src/parse.c @@ -5380,9 +5380,10 @@ Expression *Parser::parsePostExp(Expression *e) nextToken(); if (token.value == TOKidentifier) { Identifier *id = token.ident; + enum TOK save; nextToken(); - if (token.value == TOKnot && peekNext() != TOKis) + if (token.value == TOKnot && (save = peekNext()) != TOKis && save != TOKin) { // identifier!(template-argument-list) TemplateInstance *tempinst = new TemplateInstance(loc, id); Objects *tiargs;
Comment #5 by kennytm — 2011-05-18T13:50:25Z
*** Issue 6031 has been marked as a duplicate of this issue. ***
Comment #6 by yebblies — 2011-07-08T22:08:57Z
Comment #7 by kennytm — 2011-07-14T00:46:04Z
*** Issue 4159 has been marked as a duplicate of this issue. ***
Comment #8 by bugzilla — 2011-08-12T12:54:49Z