Repository navigation
fix(types): order a method call only before fns of the receiver type's module - #480
Merged
Merged
Conversation
…s module A method call x.f(...) got an edge to every fn named f whose first parameter was written as a named type, in any module. A fn such as `fn get(url: String)` in a test module could then share a group with unrelated fns that call `.get(`, and its R leaked a set type parameter of another fn in the group (E0402, E0403). Only fns whose first parameter has a type defined by their own module can be found by a method call ([type.rules]), so only those get edges.
Merged
Allianaab2m
added a commit
to emela-lang/quince
that referenced
this pull request
Oct 30, 2026
0.26.1 でメソッド呼び出しの推論の問題(emela-lang/emela#480)が直り,test の helper を get のまま書いても E0403 にならなくなった.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概要
メソッド呼び出し
x.f(...)の推論順の辺(#467)を,仕様どおり「第 1 引数の型を定義するモジュールの fn」だけに張るようにします.これまではモジュールを見ずに,名前が f で第 1 引数が名前付きの型の fn すべてに辺を張っていました.quince で依存を x/dynamic v0.5.0,x/json v0.3.0,x/shape v0.3.1 に上げると,test の
fn get(url: String) -> Responseが json の.chars().get(d)や Lib 内の.get(と同じグループに入り(4 モジュール,23 個の fn),getの R に別の fn の集合型引数が漏れて E0402(test 13 本)と E0403 が出ていました.String を定義するのは core の String モジュールなので,このgetはメソッドとして呼ばれることがありません.仕様
[type.rules](メソッドの候補は x の型を定義するモジュールの fn)proposals/method-call.md変更点
check::may_be_methodで,第 1 引数に書かれた型の定義モジュール(methods::defining_module)が fn 自身のモジュールと一致するときだけ候補にする最小再現
修正前は
get: fn(String) -> Int use '1になり,mainで E0402.修正後はget: fn(String) -> Int.テスト
crates/emela-types/tests/methods.rsにa_method_call_does_not_order_before_fns_of_other_modulesを追加(修正前に失敗することを確認)cargo test --workspace,cargo clippy -p emela-types --all-targets,cargo fmt --check,scripts/spec.py checkfn get)でemela checkが通り,emela testが 15 passed既知の制約 / follow-up