mirror of
https://github.com/roc-lang/roc.git
synced 2025-12-23 08:48:03 +00:00
When calling List.get with method syntax (my_list.get(0)), the interpreter was causing a cycle in layout computation because rigid type variables weren't being properly resolved. The fix unifies the method's first parameter type with a copy of the receiver type before instantiation. This properly resolves rigid type variables (like `item` in List.get) to concrete types. A copy of the receiver type is created before unification to avoid corrupting the original type, since unification modifies both sides. This is the same approach used for no-args method dispatch (like List.first), but with the additional copy step needed because the multi-args path may reuse types across multiple method invocations. Fixes #8662 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
13 lines
232 B
Text
13 lines
232 B
Text
app [main!] { pf: platform "./platform/main.roc" }
|
|
|
|
import pf.Stdout
|
|
|
|
main! = || {
|
|
my_list = [8]
|
|
foo = my_list.get(0)
|
|
if Try.is_ok(foo) {
|
|
Stdout.line!("is ok")
|
|
} else {
|
|
Stdout.line!("is err")
|
|
}
|
|
}
|