[Issue 18199] Error with lambda in struct initializer

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Mar 19 07:57:17 UTC 2018


https://issues.dlang.org/show_bug.cgi?id=18199

--- Comment #9 from John Belmonte <john at neggie.net> ---
The attempted change to parser.d broke some code in a test application.  It's
possible to have a function body with no colon or return tokens at the top
level (e.g. a body with just a switch statement).

I also realized that the current dmd code can misinterpret a function literal
as a struct initializer as well.  Contrived, but consider the following
function body which has no colon or return at any scope:

  static MyFun foo = {
    final switch(5) {
    }
  };

So the "color or return" test is clearly not robust for discerning function
literal from struct initializer.

New plan is to try to implement a simple lookahead to test for struct
initializer.

--


More information about the Digitalmars-d-bugs mailing list