effekt-lang / effekt-lang/effekt

Overloaded function is preferred over an overloaded operation

Open
#1,324 2 comments 1 reaction 0 assignees View on GitHub
bug
Dominant language
Scala
Stars
469
Forks
41
Avg merge
1d 16h
Merged PRs (30d)
23

Description

```scala
def foo(s: String): Unit = <>

interface F { def foo(s: Int): Unit }

def main() = {
val b = box new F {
def foo(s) = ()
}
b.foo("hello")
// error: Wrong number of arguments to foo: expected 1 value argument, but got 2 value arguments
}
```
[Playground link](https://effekt-lang.org/playground.html?playground=S0lNU0jLz9cotlIILinKzEvXtFIIzcssUbBVsLHj4srMK0ktSktMTlVwU6hWQFLsmVcCU1nLxQWSyE3MzNPQBOqr5lJQKEvMUUgCspPyKxTyUstBuoGiCggTQAo1NIFitUCcpAcSU8pIzcnJV9LkqgUA&repl=CmhlbGxvV29ybGQoKQo%3D)

There's no way to call the `foo` operation of `b` here, which is very unfortunate.
I think that when both are present, we should prefer the operation as there's no way to write it otherwise.

This used to work, probably broken by #1250 -- shows up in the [Effekt8 community project](https://github.com/effekt-community/Effekt8).
Probably caused by Namer already resolving it badly.

EDIT: not broken by #1250, but Namer prefers functions over operations for `foo.bar` situations.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.