Commit graph

759 commits

Author SHA1 Message Date
Anton-4
bf165cdd75
fix #8696 2025-12-22 19:44:29 +01:00
Jared Ramirez
8fd256d220
Add list.map snapshot and use mutable var in impl 2025-12-21 11:48:09 -05:00
Jared Ramirez
44bf01d518
Add try.map_ok and try.map_err 2025-12-21 11:48:09 -05:00
Jared Ramirez
4af41808b7
Move rank check to before annotation generation 2025-12-20 17:13:06 -05:00
Fabian Schmalzried
21c4cd5dfc
Improve render helper to render lists of tags correctly (#8702)
Improve render helper to render list content correctly
2025-12-19 10:32:33 +01:00
Luke Boswell
576feb3b26
Merge pull request #8629 from roc-lang/implement-box
Implement `Box` builtin
2025-12-19 13:10:16 +11:00
Jared Ramirez
54f0045112
Update snapshots 2025-12-18 12:42:33 -05:00
Jared Ramirez
985ce728d5
Revert rank change + required type alias strategy 2025-12-18 11:16:50 -05:00
Anton-4
d4d1c9d0c4
Fix #8699 (#8701) 2025-12-17 19:54:17 +01:00
Anton-4
aad17ac6bf
fix if else fmt without {} (#8698) 2025-12-17 16:36:17 +01:00
Luke Boswell
a6601b542c
try fix return pointer alignment mismatch 2025-12-17 22:41:23 +11:00
Luke Boswell
8c75408a0d
Merge pull request #8695 from roc-lang/cli-err-reporting
Refactor cli
2025-12-17 21:21:44 +11:00
Luke Boswell
f6430cb5c6
Merge remote-tracking branch 'remote/cli-err-reporting' into implement-box-with-cli-err-reporting 2025-12-17 15:28:54 +11:00
Luke Boswell
42937e1728
fix windows targets for test platforms 2025-12-17 14:35:16 +11:00
Richard Feldman
12dac2cec7
Merge pull request #8669 from roc-lang/fix-issue-8666
Fix panic when using polymorphic numeric as list index
2025-12-16 21:24:55 -05:00
Luke Boswell
aad6395974
WIP - migrate to cli ctx 2025-12-17 11:08:22 +11:00
Luke Boswell
654fbed061
fix str platform imports 2025-12-17 09:08:56 +11:00
Richard Feldman
82673a0f76
Merge pull request #8690 from roc-lang/fix-issue-8689
Fix field access on record payload in tag union wrapped by opaque type
2025-12-16 13:35:32 -05:00
Richard Feldman
03535a5786
Convert fx test to eval snapshot test for issue #8689
The eval snapshot test is faster and more appropriate since the bug
is in the canonicalization phase. The test verifies both that the
code canonicalizes correctly (no incorrect captures) and that it
evaluates correctly at runtime.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-16 12:14:25 -05:00
Fabian Schmalzried
22159f2c5c
Add List.repeat builtin (#8688)
* Add List.repeat builtin

* format Builtin.roc
2025-12-16 14:27:51 +01:00
Richard Feldman
641f4db0b0
Update snapshots for nominal pattern bound variable fix
The fix correctly identifies that variables bound inside nominal
patterns (like `s` in `Container.Box(s)`) are bound in the pattern
scope and don't need to be captured. This results in cleaner
canonical IR where functions that use nominal pattern matching
are now represented as pure lambdas instead of closures with
unnecessary captures.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-16 07:55:22 -05:00
Richard Feldman
9f143f79ec
Fix nominal pattern bound variable collection (issue #8689)
collectBoundVarsToScratch was not recursing into the backing pattern
for nominal and nominal_external patterns. This caused variables
bound in nominal patterns (e.g., Wrapper.Simple(s)) to not be tracked
as bound variables, leading to them incorrectly being included in the
free variables of match expression bodies.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-16 07:53:38 -05:00
Luke Boswell
2edc1f4c86 fix windows targets for test platforms 2025-12-16 23:12:39 +11:00
Luke Boswell (Linux-Desktop)
83266eb7b0
merge changes from remote/main 2025-12-17 06:57:47 +11:00
Luke Boswell
7b31e3204c
fix recursive addTypeVar corrupting work stack
The layout computation's addTypeVar function was clearing work fields
(pending_record_fields, pending_tuple_fields, pending_tags, etc.) at
the start of every call via clearRetainingCapacity(). This caused
corruption when processing nested types that trigger recursive calls.

Example problem case:
  { tag: Str, attrs: List([StringAttr(Str, Str), BoolAttr(Str, Bool)]) }

When processing this record:
1. Record handling pushes fields to pending_record_fields
2. Processing the List element triggers tag union handling
3. Tag union handling makes recursive addTypeVar calls for variant payloads
4. These recursive calls cleared pending_record_fields
5. When returning to finalize the outer record, pop() found empty stack

The fix removes clearRetainingCapacity entirely. All work fields now
persist across recursive calls and are cleaned up individually:
- pending_containers: pop() when container layout is finalized
- in_progress_vars: swapRemove() when type is cached
- pending_record_fields: pop() when field is resolved
- pending_tags: shrinkRetainingCapacity() via defer

This fixes the unreachable panic in roc-dom when rendering elements
with complex nested types like List([String(Str,Str), Bool(Str,Bool)]).

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-16 22:32:28 +11:00
Luke Boswell
1b68e035b0
replace unreachable with debug helper in interpreter 2025-12-16 17:46:58 +11:00
Luke Boswell
cd6a5900c6
fix multi-module platform exposes and add str platform tests
Fix a bug where platforms exposing multiple modules would fail at runtime
with "nested value not found" errors when modules call each other's methods.

Root cause: compileAndSerializeModulesForEmbedding was passing module names
in the wrong order (exposed_modules.items vs sorted_modules), and wasn't
passing type module names when compiling sibling platform modules.

Changes:
- src/cli/main.zig: Pass sorted_modules as type module names when compiling
  platform modules, platform main, and app modules
- src/eval/interpreter.zig: Improve error messages for nested_value_not_found
- src/canonicalize/Can.zig: Add trace output for nested_value_not_found

Test infrastructure:
- Add SimpleTestSpec and simple_list variant to platform_config.zig
- Add 8 str platform tests covering direct calls, transitive calls, and
  diamond dependency patterns
- Update test_runner.zig to handle simple_list
- Add test_runner invocations for int and str platforms to build.zig
- Make CLI tests run sequentially to avoid cache race conditions

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-16 17:10:56 +11:00
Luke Boswell
0a6817b72e
expand scope of @panic purge 2025-12-16 16:16:04 +11:00
Luke Boswell
f20e945cb9
fix tests 2025-12-16 13:33:53 +11:00
Luke Boswell
fba022121c
improve tests for module dependency ordering 2025-12-16 11:48:15 +11:00
Luke Boswell
2bdbe87be0
add trace_modules feature 2025-12-16 11:25:17 +11:00
Luke Boswell
d499420a0f
cleanup doc comments 2025-12-16 10:35:39 +11:00
Luke Boswell
132658fa15
fix: transitive module imports in compile-time evaluation
Fix "TypeMismatch in body evaluation" panic when platform modules make
transitive calls (e.g., app → Helper → Core).

Changes:
- Pass sibling modules during platform module compilation so each module
  can resolve imports to previously compiled siblings
- Detect type modules (using `:= [].{}` syntax) and set statement_idx
  for proper qualified name lookup during canonicalization
- Pre-allocate compiled_modules ArrayList to avoid pointer invalidation
  during reallocation
- Add fallback to env.imports.getResolvedModule in evalLookupExternal
  for cross-module calls when current module context has changed
- Fix use-after-free bug in low_level_interp_test.zig by heap-allocating
  imported_envs array
- Add integration test for transitive module imports

Note: Modules must be listed in dependency order in the platform's
exposes list (e.g., if Helper imports Core, Core must come before Helper).

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-16 10:21:46 +11:00
Luke Boswell
0edb5fe2df
Merge remote-tracking branch 'remote/fix-issue8654' into implement-box 2025-12-16 07:29:48 +11:00
Luke Boswell
7694fc5d42
Merge remote-tracking branch 'remote/main' into implement-box 2025-12-16 07:17:45 +11:00
Anton-4
113fff55a2
fix #8654 2025-12-15 19:39:01 +01:00
Anton-4
60336fd1a5
expand all_syntax_test (#8685) 2025-12-15 19:20:23 +01:00
Luke Boswell
79c0cbb04b
Merge remote-tracking branch 'remote/main' into implement-box 2025-12-15 20:01:23 +11:00
Luke Boswell
4e4eef2d04
fix infinite recursion bug (again) 2025-12-15 15:18:49 +11:00
Richard Feldman
b7c9c16f9f
Fix polymorphic numeric let-generalization (issue #8666)
The root cause was that numeric literals with `from_numeral` constraints
were being generalized (let-polymorphism), causing each lookup to create
a fresh instantiation. This meant constraints from later usage (like
List.get expecting U64) didn't propagate back to the original definition,
leaving the value as an unconstrained flex var that defaulted to Dec.

Fix:
1. In generalize.zig: Don't generalize flex vars with `from_numeral`
   constraints at ANY rank (not just top_level)
2. In Check.zig: Don't instantiate during lookup if the var has a
   `from_numeral` constraint - unify directly instead

This aligns with the design that let-generalization should only work for
things that are syntactically lambdas (e.g. `foo = |arg| ...`).

Also reverts the interpreter workaround - the proper fix is in the type
checker, not working around type system bugs in the interpreter.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-14 22:38:11 -05:00
Richard Feldman
e8b2c4dff1
Merge pull request #8674 from godalming123/main
Show code for unimplemented error messages
2025-12-14 19:25:23 -05:00
Luke Boswell
940abf6793
add for_clause_alias_statements for platform headers 2025-12-15 10:04:21 +11:00
godalming123
857f0e1d3e Fix tests 2025-12-14 13:32:20 +00:00
Luke Boswell
b541a6b6db
Merge remote-tracking branch 'remote/main' into implement-box 2025-12-14 19:01:56 +11:00
Richard Feldman
79a08d5d0f
Fix List.get with method syntax causing cycle in layout computation
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>
2025-12-13 15:43:09 -05:00
Richard Feldman
c68d5c2ed9
Make main be a record, not a thunk 2025-12-12 23:49:10 -05:00
Richard Feldman
1697428254
Update size check 2025-12-12 22:13:12 -05:00
Richard Feldman
3be74028f7
Merge remote-tracking branch 'origin/main' into implement-box 2025-12-12 21:56:27 -05:00
Richard Feldman
58cede45b2
Add for clauses to platform modules 2025-12-12 21:21:51 -05: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