chapel icon indicating copy to clipboard operation
chapel copied to clipboard

[Bug]: cannot call defaulted interface method directly

Open jabraham17 opened this issue 6 months ago • 0 comments

The following code does not compile today, as the compiler does not recognize that foo is a method of B.

interface A {
  proc Self.foo(x: int): void {
    writeln("x ", x);
  }
}

record B: A {
}
var x = new B();
x.foo(11);

This gives the following error:

foo.chpl:10: error: unresolved call 'B.foo(11)'
foo.chpl:10: note: because no functions named foo found in scope

However, the following does work

interface A {
  proc Self.foo(x: int): void {
    writeln("x ", x);
  }
}

record B: A {
}
var x = new B();

proc callFoo(x: A) do x.foo(10);
callFoo(x);

jabraham17 avatar Aug 22 '24 16:08 jabraham17