www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 20808] New: [regression] opDispatch error disappears!

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

          Issue ID: 20808
           Summary: [regression] opDispatch error disappears!
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Keywords: accepts-invalid
          Severity: major
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: destructionator gmail.com

With this specific jsvar commit:

https://raw.githubusercontent.com/adamdruppe/arsd/643d548245adac27517504a51e3a52a8bc9be69f/jsvar.d

and this test program:

---
import arsd.jsvar;

void printInt(const int value)
{
    assert(0);
}

void main(string [] args)
{
    var globals = var.emptyObject;
    globals.printInt = &printInt;
    //globals["printInt"] = &printInt;
}
---

That globals.printInt line calls opDispatch. On dmd 2.088, it issued an error

Error: function pil.printInt(const(int) value) is not callable using argument
types (var, void function(const(int) value))
      cannot pass argument globals of type var to parameter const(int) value


(which itself is weird, cuz opDispatch frequently gives the useless "no such
property" error. so i thought this was a welcome fix but it is still strings)

On v2.091.1... it compiles! But does nothing. Obviously it didn't do what it is
supposed to do.

The commented line there calls opIndexAssign. Note that the implementation of
opDispatch forwards directly to opIndexAssign, so if one fails, the other
should fail to compile as well.

The commented line yields a correct compile error:

arsd/jsvar.d(681): Error: cannot modify constant cast(int)__fargs_field_0
arsd/jsvar.d(1355): Error: template instance arsd.jsvar.var.opAssign!(void
function(const(int)))
rror instantiating
arsd/jsvar.d(1311):        instantiated from here: opIndexAssign!(void
function(const(int)))
pil.d(12):        instantiated from here: opIndexAssign!(void
function(const(int) value))
arsd/jsvar.d(1319): Error: template instance arsd.jsvar.var.__ctor!(void
function(const(int))) error instantiating
pil.d(12):        instantiated from here: opIndexAssign!(void
function(const(int) value))



So opDispatch is completely swallowing a compile error in this version that it
used to treat differently before. Something weird is going on but I haven't
figured out how to reduce it from the full library yet.

--
May 08