effekt-lang / effekt-lang/effekt

Name resolution for method calls is inconsistent

Open
#1,397 1 comment 0 reactions 0 assignees View on GitHub
requires-design
Dominant language
Scala
Stars
469
Forks
41
Avg merge
1d 16h
Merged PRs (30d)
23

Description

What should be the overloading/unboxing behavior, actually? Currently, it seems all over the place, to the best of my current understanding:
`value.foo(...){...}` (a) is different from `block.foo(...){...}` (b) is different from `foo(...){...}` (c).

- (a) will be overloaded with just functions if there is a function foo  in scope, overloaded with just operations if there is an operation in scope, and only otherwise resolve to a block parameter of the innermost function that has any (the comment here is misleading); An unbox will be inserted if there is an operation in the CallTarget  afterwards. Implemented here: https://github.com/effekt-lang/effekt/blob/b734023bddab0b6c677b92698d5246dbf45db272/effekt/shared/src/main/scala/effekt/Namer.scala#L1142
- (b) will be overloaded with just operations if there is an operation in scope*, else overloaded with functions only, and **never resolve to a block parameter**. Implemented here: https://github.com/effekt-lang/effekt/blob/b734023bddab0b6c677b92698d5246dbf45db272/effekt/shared/src/main/scala/effekt/Namer.scala#L1130
- (c) will resolve to functions or block parameters, unless there is a value in a closer scope, in which case it will resolve to that. Implemented here: https://github.com/effekt-lang/effekt/blob/b734023bddab0b6c677b92698d5246dbf45db272/effekt/shared/src/main/scala/effekt/Namer.scala#L1160

#### Examples where this acts weirdly:
- https://effekt-lang.org/playground.html?playground=TU27CsIwFN3vV5yxWdrBoSC4OAh%2BRlpvNJDcK2m0Acm%2Fm%2Bqg23mfCzs41c7scZaMA3bjiGHArDGyZC9X5JtfELwwnC%2B8NM7glDRh4qBrT%2BQlc3J2ZpxU8SLgb%2FaoGqgSbVK0XjrTXrbM0waUhictEF6%2F3V%2BzOTk9GLVF76ldBOlK%2F7EM1Tc%3D&repl=bWFpbigp
- https://effekt-lang.org/playground.html?playground=TY0xDsIwEAT7e8WWdpMUFJGQaCiQeEYIZ7Dk3KGLUZAi%2Fx2bhpS7mtm9c0BQdf6Iq2SccBgG9D0mnWeWHOWB%2FIwLUhRGiB9eamawmRpunHTtiKJktjBOjIsqNgJ2s2fVRIWoVfMYxfn60piXVS%2BJc8JrE7e%2FVYlsb0bx3S97Kl8%3D&repl=bWFpbigp
- https://effekt-lang.org/playground.html?playground=S0lNU0jJLC7ISazUqLBS8Mwr0bRSCC4pysxLV7BVqNArzsgv5%2BICqUpKLIp2jAUpctSsVrCH6QJyFWztYFpqUTRDlUD05yZm5mloAsULgPIlOXkaQAM1DI00NQE%3D&repl=bWFpbigp (even worse with `show`).

#### Related issues
- #670 lead to some of the inconsistencies above (but should still work)

### Possible directions for solutions
- Move box-unbox-inference into typer and overload between all of them
- Drop the distinction between blocks/values

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.