Commit graph

36439 commits

Author SHA1 Message Date
Richard Feldman
c4e1e337eb
Remove redundant fx test for issue 8664
The bug is already covered by the faster eval test in eval_test.zig.
The fx platform test is not needed since the bug is purely in the
interpreter's for loop element type handling.
2025-12-13 19:29:47 -05:00
Richard Feldman
a7ce3988ac
Merge origin/main 2025-12-13 17:51:55 -05:00
Richard Feldman
117448f347
Fix double-close crash in downloadToFile error handling
When HTTP fetch or flush failed, the code explicitly closed the file
and deleted it before returning an error. But returning an error also
triggered the errdefer block which tried to close the file again,
causing a crash on Windows where CloseHandle asserts success.

The fix removes the explicit close/delete calls in error paths since
the errdefer already handles cleanup. The errdefer pattern is the
correct way to handle this - it ensures cleanup happens exactly once
whether we return normally or with an error.
2025-12-13 17:51:14 -05:00
Richard Feldman
648562a0fb
Add test reproducing double-close crash in downloadToFile
When an HTTP fetch fails, downloadToFile explicitly closes the file
before returning an error. The error return then triggers the errdefer
block which tries to close the file again, causing a crash.

This test uses an unreachable URL (localhost port 1) to trigger the
HTTP error path and reproduce the double-close bug.
2025-12-13 17:49:34 -05:00
Richard Feldman
19f5162a46
Merge pull request #8659 from roc-lang/fix-issue-8647
Fix TypeMismatch error on record field access during evaluation
2025-12-13 17:31:18 -05:00
Richard Feldman
e4173cf752
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>
2025-12-13 15:50:01 -05:00
Richard Feldman
9458da9a83
Fix InvalidMethodReceiver when iterating over untyped list parameter
When a for loop iterates over a list passed to a function with no type
annotation, the pattern's compile-time type variable was a flex
variable. This translated to a runtime flex type, which caused
InvalidMethodReceiver when trying to call methods like .to_str() on the
loop elements.

The fix extracts the element type from the list's actual runtime type
(e.g., List(I64)) instead of using the pattern's translated type. This
ensures method resolution has the concrete nominal type information it
needs.

Fixes #8664

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-13 15:35:28 -05:00
Richard Feldman
4932d12909
Remove CLI test, keep only eval unit tests for issue #8647
The fix is an interpreter change, so eval_test.zig tests are sufficient.
Removed the fx platform test file and spec.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-13 15:07:22 -05:00
Richard Feldman
576b4b7a31
Merge remote-tracking branch 'origin/main' into fix-issue-8647 2025-12-13 15:04:37 -05:00
Richard Feldman
9f884cf80b
Merge pull request #8661 from roc-lang/fix-issue-8650
Fix use-after-free in List.append with tuples containing strings
2025-12-13 15:02:32 -05:00
Richard Feldman
566673b787
Merge pull request #8658 from roc-lang/fix-issue-8656
Fix rank panic when variable redirects to higher-rank variable
2025-12-13 15:01:44 -05:00
Richard Feldman
d0d53b20ef
Convert issue8656 to type-checker test
Move the regression test from a CLI test to a type-checker unit test
since it only tests type checking behavior.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-13 10:30:32 -05:00
Richard Feldman
ee1049ffb3
Fix use-after-free in List.append with tuples containing strings
Issue #8650: List.append wasn't properly incrementing refcounts for strings
inside tuples. The root cause was that isRefcounted() returns false for
tuples (they aren't directly heap-allocated), but tuples can transitively
contain refcounted data like strings.

Added layoutContainsRefcounted() helper function that checks if a layout
transitively contains any refcounted data (strings, lists, boxes), including
nested tuples, records, and tag unions. This is used in list_append to
determine when element incref/decref callbacks are needed.

Note: This fix is for the interpreter path. The compiled code path (LLVM)
would need a similar fix in the Rust codegen, but that is out of scope
for this change.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-13 09:49:26 -05:00
Richard Feldman
e093bd1fb3
Fix TypeMismatch error on record field access during evaluation
The interpreter was unconditionally defaulting flex/rigid type variables
to Dec for all dot access expressions. This broke record field access
when the record type wasn't fully resolved at compile time, because
records are not Dec.

The fix distinguishes between method calls (args != null) and field
access (args == null). Only method calls with flex/rigid receivers
default to Dec, since numeric literals like `(-3.14).abs()` need this
for proper type resolution. Field access passes null for expected_rt_var
to let the receiver determine its own type.

Additionally, in dot_access_resolve, field names must be translated
from the CIR's identifier store to the runtime layout store's identifier
store, since these can differ between modules.

Fixes #8647

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-13 09:45:19 -05:00
Richard Feldman
930fd0865e
Fix rank panic when variable redirects to higher-rank variable
When a variable added to var_pool at rank 1 was later redirected (via
setVarRedirect) to a variable at rank 2, generalization would try to
add the resolved variable at rank 2 to tmp_var_pool which only goes up
to rank 1, causing a panic.

The fix caps the effective rank at rank_to_generalize when copying
variables to tmp_var_pool. This allows the rank adjustment phase to
properly handle these variables.

Fixes #8656

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-13 09:43:26 -05:00
Anton-4
6fabcdeb0e
retry on connectTcp flaky (#8652)
Cleared roc cache at C:\Users\runneradmin\AppData\Roaming\Roc Build succeeded! test +- tests_summary    +- run test fx_platform_test 35/36 passed, 1 failed error: 'fx_platform_test.test.external platform memory alignment regression' failed: Run failed with exit code 3 STDOUT:  STDERR: thread 2760 panic: reached unreachable code C:\a\_temp\0f24a2ca-ec71-410b-9a5b-1091de9378c7\zig-aarch64-windows-0.15.2\lib\std\fs\Dir.zig:1642:35: 0x7ff65697cb67 in makeOpenDirAccessMaskW (roc_zcu.obj)         .OBJECT_PATH_NOT_FOUND => return error.FileNotFound,                                   ^ C:\a\_temp\0f24a2ca-ec71-410b-9a5b-1091de9378c7\zig-aarch64-windows-0.15.2\lib\std\fs\Dir.zig:1574:21: 0x7ff6567c91b7 in openDirW (roc_zcu.obj)         else => |e| return e,                     ^ C:\a\_temp\0f24a2ca-ec71-410b-9a5b-1091de9378c7\zig-aarch64-windows-0.15.2\lib\std\fs\Dir.zig:1448:13: 0x7ff6565e253b in openDir (roc_zcu.obj)             return self.openDirW(sub_path_w.span().ptr, args);             ^ C:\a\_temp\0f24a2ca-ec71-410b-9a5b-1091de9378c7\zig-aarch64-windows-0.15.2\lib\std\net.zig:937:39: 0x7ff656b14e57 in getAddressList (roc_zcu.obj)                 .WSAHOST_NOT_FOUND => return error.UnknownHostName,                                       ^ C:\a\_temp\0f24a2ca-ec71-410b-9a5b-1091de9378c7\zig-aarch64-windows-0.15.2\lib\std\net.zig:837:18: 0x7ff656d79307 in tcpConnectToHost (roc_zcu.obj)     const list = try getAddressList(allocator, name, port);                  ^ C:\a\_temp\0f24a2ca-ec71-410b-9a5b-1091de9378c7\zig-aarch64-windows-0.15.2\lib\std\http\Client.zig:1441:34: 0x7ff656d2b843 in connectTcpOptions (roc_zcu.obj)         error.UnknownHostName => return error.UnknownHostName,                                  ^ C:\a\_temp\0f24a2ca-ec71-410b-9a5b-1091de9378c7\zig-aarch64-windows-0.15.2\lib\std\http\Client.zig:1408:5: 0x7ff656d2bbdb in connectTcp (roc_zcu.obj)     return connectTcpOptions(client, .{ .host = host, .port = port, .protocol = protocol });     ^ C:\a\_temp\0f24a2ca-ec71-410b-9a5b-1091de9378c7\zig-aarch64-windows-0.15.2\lib\std\http\Client.zig:1583:14: 0x7ff656cbfb57 in connect (roc_zcu.obj)     } orelse return client.connectTcp(host, port, protocol);              ^ C:\a\_temp\0f24a2ca-ec71-410b-9a5b-1091de9378c7\zig-aarch64-windows-0.15.2\lib\std\http\Client.zig:1699:18: 0x7ff656c1785f in request (roc_zcu.obj)         break :c try client.connect(host_name, uriPort(uri, protocol), protocol);                  ^ C:\a\_temp\0f24a2ca-ec71-410b-9a5b-1091de9378c7\zig-aarch64-windows-0.15.2\lib\std\http\Client.zig:1789:15: 0x7ff656b15adf in fetch (roc_zcu.obj)     var req = try request(client, method, uri, .{               ^ C:\a\_temp\0f24a2ca-ec71-410b-9a5b-1091de9378c7\zig-aarch64-windows-0.15.2\lib\std\debug.zig:559:14: 0x7ff656564ac7 in assert (roc_zcu.obj)     if (!ok) unreachable; // assertion failure              ^ C:\a\_temp\0f24a2ca-ec71-410b-9a5b-1091de9378c7\zig-aarch64-windows-0.15.2\lib\std\os\windows.zig:596:11: 0x7ff6565673bf in CloseHandle (roc_zcu.obj)     assert(ntdll.NtClose(hObject) == .SUCCESS);           ^ C:\a\_temp\0f24a2ca-ec71-410b-9a5b-1091de9378c7\zig-aarch64-windows-0.15.2\lib\std\fs\File.zig:204:28: 0x7ff65656e1db in close (roc_zcu.obj)         windows.CloseHandle(self.handle);                            ^ C:\a\roc\roc\src\unbundle\download.zig:249:23: 0x7ff6569c052b in downloadToFile (roc_zcu.obj)             file.close();                       ^ C:\a\roc\roc\src\unbundle\download.zig:134:45: 0x7ff656817ddb in downloadAndExtract (roc_zcu.obj)     const temp_filename = try downloadToFile(allocator, url, extract_dir, base58_hash, &temp_filename_buf);                                             ^ C:\a\roc\roc\src\cli\main.zig:2994:40: 0x7ff65664157f in resolveUrlPlatform (roc_zcu.obj)             download.downloadAndExtract(&gpa_copy, url, new_package_dir) catch |download_err| {                                        ^ C:\a\roc\roc\src\cli\main.zig:2890:34: 0x7ff6566480b7 in resolvePlatformSpecToPaths (roc_zcu.obj)         return resolveUrlPlatform(allocs, platform_spec);                                  ^ C:\a\roc\roc\src\cli\main.zig:972:54: 0x7ff656645b67 in rocRun (roc_zcu.obj)     const platform_paths = resolvePlatformSpecToPaths(allocs, platform_spec, app_dir) catch |err| {                                                      ^ C:\a\roc\roc\src\cli\main.zig:739:23: 0x7ff6567c42b3 in mainArgs (roc_zcu.obj)             try rocRun(allocs, run_args);                       ^ C:\a\roc\roc\src\cli\main.zig:678:13: 0x7ff6567c5923 in main (roc_zcu.obj)     mainArgs(&allocs, args) catch {             ^ C:\a\_temp\0f24a2ca-ec71-410b-9a5b-1091de9378c7\zig-aarch64-windows-0.15.2\lib\std\start.zig:602:28: 0x7ff6567c5efb in main (roc_zcu.obj)     return callMainWithArgs(@as(usize, @intCast(c_argc)), @as([*][*:0]u8, @ptrCast(c_argv)), envp);                            ^ C:\a\_temp\0f24a2ca-ec71-410b-9a5b-1091de9378c7\zig-aarch64-windows-0.15.2\lib\libc\mingw\crt\crtexe.c:259:0: 0x7ff65701a2bb in __tmainCRTStartup (crt2.obj)     mainret = _tmain (argc, argv, envp);  C:\a\_temp\0f24a2ca-ec71-410b-9a5b-1091de9378c7\zig-aarch64-windows-0.15.2\lib\libc\mingw\crt\crtexe.c:179:0: 0x7ff65701a327 in mainCRTStartup (crt2.obj)   ret = __tmainCRTStartup ();  ???:?:?: 0x7ffbb394873f in ??? (KERNEL32.DLL) ???:?:?: 0x7ffbb6ae4463 in ??? (ntdll.dll)  C:\a\roc\roc\src\cli\test\fx_platform_test.zig:69:17: 0x7ff65e775a4f in checkSuccess (fx_platform_test_zcu.obj)                 return error.RunFailed;                 ^ C:\a\roc\roc\src\cli\test\fx_platform_test.zig:1163:5: 0x7ff65e780943 in test.external platform memory alignment regression (fx_platform_test_zcu.obj)     try checkSuccess(run_result);     ^ error: while executing test 'fx_test_specs.test.find by path works', the following test command failed: "C:\\Users\\runneradmin\\AppData\\Local\\zig\\o\\47d06347fb2b8bb1799a7b19156ede3f\\fx_platform_test.exe" "--cache-dir=C:\\Users\\runneradmin\\AppData\\Local\\zig" --seed=0x59c23868 --listen=-  Build Summary: 86/89 steps succeeded; 1 failed; 1908/1912 tests passed; 3 skipped; 1 failed test transitive failure +- tests_summary transitive failure    +- run test fx_platform_test 35/36 passed, 1 failed  error: the following build command failed with exit code 1: C:\Users\runneradmin\AppData\Local\zig\o\8f4b00b4a8d55e5b952be7182a09f3b9\build.exe C:\a\_temp\0f24a2ca-ec71-410b-9a5b-1091de9378c7\zig-aarch64-windows-0.15.2\zig.exe C:\a\_temp\0f24a2ca-ec71-410b-9a5b-1091de9378c7\zig-aarch64-windows-0.15.2\lib C:\a\roc\roc C:\Users\runneradmin\AppData\Local\zig C:\Users\runneradmin\AppData\Local\zig --seed 0x59c23868 -Z96370e066f7f6be0 test -Dfuzz -Dsystem-afl=false

Signed-off-by: Anton-4 <17049058+Anton-4@users.noreply.github.com>
2025-12-12 19:16:11 +01:00
Anton-4
aa2e1b80cd
All roc syntax test (#8622)
* added all_roc_syntax_test

* fmt + test

* full test

---------

Signed-off-by: Anton-4 <17049058+Anton-4@users.noreply.github.com>
2025-12-12 18:07:03 +01:00
Richard Feldman
f8fbc2932d
Merge pull request #8651 from roc-lang/list-join-with
Add `List.join_with`
2025-12-12 11:38:12 -05:00
Richard Feldman
9cd58ee4ab
Merge pull request #8649 from roc-lang/fix-double-decref
Fix double-decref
2025-12-12 10:05:53 -05:00
Richard Feldman
6efd449282
Add List.join_with with type var alias dispatch 2025-12-12 09:21:52 -05:00
Richard Feldman
b2dea15a3e
Add test for small string input in Stdin.line! while loop 2025-12-12 09:08:34 -05:00
Richard Feldman
dce64de490
Merge pull request #8639 from roc-lang/expand-type-var-alias
Add test case for type var alias
2025-12-12 09:04:13 -05:00
Richard Feldman
fae5ddbbe3
Fix double-decref bug in binop_apply and unary_op_apply
When handling low-level lambdas (like Str.is_eq), the code was decrefing
arguments with borrow semantics, but the defer statements at the top of
these functions already handle decrefing. This caused a double-free when
comparing heap-allocated strings (24+ characters).

The fix removes the explicit decrefs in the low-level lambda paths since
the defer statements already handle cleanup.
2025-12-12 09:01:54 -05:00
Anton-4
41815e7b02
fix #8641 (#8644) 2025-12-12 13:28:25 +01:00
Richard Feldman
e1019be2ef
Merge pull request #8627 from roc-lang/fix-another-aoc
Fix tag union handling
2025-12-12 07:09:54 -05:00
Anton-4
33cf64377f
fix pipe retry action (#8640) 2025-12-12 12:35:05 +01:00
Anton-4
0608d4c338
Fix #8517 (#8613)
temp fix expect stack overflow

Signed-off-by: Anton-4 <17049058+Anton-4@users.noreply.github.com>
2025-12-12 11:30:33 +01:00
Richard Feldman
158cd650f1
Merge origin/main into fix-another-aoc
Resolved merge conflicts in:
- src/cli/test/fx_test_specs.zig (combined test entries from both branches)
- test/snapshots/fuzz_crash/fuzz_crash_027.md (took main's version)
- test/snapshots/fuzz_crash/fuzz_crash_028.md (took main's version)
2025-12-11 23:24:23 -05:00
Richard Feldman
f0cf4e2007
Merge origin/main into fix-another-aoc
Resolved merge conflicts in:
- src/cli/test/fx_test_specs.zig (combined test entries from both branches)
- test/snapshots/fuzz_crash/fuzz_crash_027.md (took main's error message format)
- test/snapshots/fuzz_crash/fuzz_crash_028.md (took main's error message format)
2025-12-11 23:18:39 -05:00
Richard Feldman
a6c2c30661
Merge pull request #8638 from roc-lang/fix-list-first-panic-8633
Fix List.first dispatch panic
2025-12-11 23:05:16 -05:00
Richard Feldman
857b5c27f7
Add from_str test case for type var alias 2025-12-11 23:04:39 -05:00
Richard Feldman
3947f718f6
Merge pull request #8636 from roc-lang/type-var-alias
Static dispatch on non-args
2025-12-11 22:51:48 -05:00
Richard Feldman
3956e185fe
Update docs 2025-12-11 22:15:18 -05:00
Richard Feldman
cdafc209b9
Merge origin/main into fix-list-first-panic-8633
Resolved conflict in fx_test_specs.zig by including both:
- list_append_stdin_uaf.roc test from main
- list_first_method.roc and list_first_function.roc regression tests from this branch

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-11 21:43:44 -05:00
Richard Feldman
2d863e9073
Fix panics 2025-12-11 21:13:15 -05:00
Richard Feldman
9a4bfebf20
Merge pull request #8635 from roc-lang/fix-refcount
Add a missing refcount
2025-12-11 17:25:20 -05:00
Richard Feldman
c99b06f2e5
Improve test coverage for type variable alias static dispatch 2025-12-11 16:37:13 -05:00
Richard Feldman
28d5ab5602
Implement type variable alias for static dispatch on type parameters 2025-12-11 16:37:12 -05:00
Richard Feldman
c7fd764eb3
Add snapshot test for type var alias static dispatch 2025-12-11 16:37:07 -05:00
Richard Feldman
1c6c649744
Implement type checking and interpreter for type var dispatch 2025-12-11 16:36:52 -05:00
Richard Feldman
e888ce0b6d
Add type var alias stmt and type var dispatch expr 2025-12-11 16:36:28 -05:00
Richard Feldman
b6428ef704
Merge pull request #8631 from roc-lang/aligncast-helper
Update alignCast to use new helper
2025-12-11 16:35:01 -05:00
Richard Feldman
0d2e91a998
Merge pull request #8632 from roc-lang/type-checker-stuff
Fix some more type checker error handling
2025-12-11 16:34:50 -05:00
Richard Feldman
a3d68dbc37
Add a missing refcount 2025-12-11 16:32:07 -05:00
Richard Feldman
fd874201b3
More occurs fixes 2025-12-11 15:25:50 -05:00
Richard Feldman
f92d84323e
Fix tests 2025-12-11 11:49:45 -05:00
Richard Feldman
b660d54c40
Update test 2025-12-11 11:46:15 -05:00
Richard Feldman
ca1a1fa5a6
Fix tag union handling 2025-12-11 11:46:15 -05:00
Richard Feldman
a9878630cc
Refactor to alignedPtrCast 2025-12-11 11:30:06 -05:00
Richard Feldman
8239f7a053
Update alignCast to use new helper 2025-12-11 08:07:29 -05:00