www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 21449] New: parser reject constructor call to


          Issue ID: 21449
           Summary: parser reject constructor call to
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Keywords: rejects-valid
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: b2.temp gmx.com

using the ctor as an unary in an expstmt is an error (no effect) but for static
opCall this can be valid.

struct Foo
    static opCall(T)(T t){}

void main()
    Foo(0);         //OK
    const(Foo(0));  //NG

/tmp/temp_7F00CFE49E90.d:13:14: Error: unexpected `(` in declarator
/tmp/temp_7F00CFE49E90.d:13:15: Error: basic type expected, not `0`
/tmp/temp_7F00CFE49E90.d:13:15: Error: found `0` when expecting `)`
/tmp/temp_7F00CFE49E90.d:13:17: Error: no identifier for declarator `const
/tmp/temp_7F00CFE49E90.d:13:17: Error: semicolon expected following function
/tmp/temp_7F00CFE49E90.d:13:17: Error: found `)` instead of statement
found by Herringway as seen on IRC. --
Dec 03 2020