mirror of
https://github.com/roc-lang/roc.git
synced 2025-12-23 08:48:03 +00:00
Add faster eval test for issue 8664 and use unsuffixed numbers
The bug only occurs with unsuffixed number literals (which default to Dec), not with suffixed ones like 8i64. Update the fx test to use unsuffixed numbers to properly reproduce the bug, and add a faster eval test that verifies the same behavior. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
9458da9a83
commit
e4173cf752
3 changed files with 22 additions and 2 deletions
|
|
@ -240,7 +240,7 @@ pub const io_spec_tests = [_]TestSpec{
|
|||
},
|
||||
.{
|
||||
.roc_file = "test/fx/issue8664.roc",
|
||||
.io_spec = "1>num: 8|1>num: 7|1>result: 7",
|
||||
.io_spec = "1>num: 8.0|1>num: 7.0|1>result: 7.0",
|
||||
.description = "Regression test: Issue #8664 - InvalidMethodReceiver when calling methods on elements from untyped list parameter",
|
||||
},
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1406,3 +1406,23 @@ test "List.len returns proper U64 nominal type for method calls - regression" {
|
|||
\\}
|
||||
, "3", .no_trace);
|
||||
}
|
||||
|
||||
test "for loop element type extracted from list runtime type - regression #8664" {
|
||||
// Regression test for InvalidMethodReceiver when calling methods on elements
|
||||
// from a for loop over a list passed to an untyped function parameter.
|
||||
// The fix: extract element type from list's runtime type (e.g., List(Dec))
|
||||
// instead of using the pattern's compile-time flex variable.
|
||||
// Note: unsuffixed number literals default to Dec in Roc.
|
||||
try runExpectStr(
|
||||
\\{
|
||||
\\ calc = |list| {
|
||||
\\ var $result = ""
|
||||
\\ for elem in list {
|
||||
\\ $result = elem.to_str()
|
||||
\\ }
|
||||
\\ $result
|
||||
\\ }
|
||||
\\ calc([1, 2, 3])
|
||||
\\}
|
||||
, "3.0", .no_trace);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ calc = |line| {
|
|||
}
|
||||
|
||||
main! = || {
|
||||
line = [8i64, 7i64, 6i64]
|
||||
line = [8, 7, 6]
|
||||
num = calc(line)
|
||||
Stdout.line!("result: ${num.to_str()}")
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue