Skip to content

Fix multiple issues: type inference, syntax, CI, and correctness#6

Merged
jakeuribe merged 17 commits intomainfrom
claude/investigate-branch-issue-KgkdQ
Feb 22, 2026
Merged

Fix multiple issues: type inference, syntax, CI, and correctness#6
jakeuribe merged 17 commits intomainfrom
claude/investigate-branch-issue-KgkdQ

Conversation

@jakeuribe
Copy link
Owner

@jakeuribe jakeuribe commented Feb 22, 2026

Summary

Fixes ported from upstream issues and PRs in google-research/dex-lang:

  • PR #692: Enable parallel test execution in CI
  • PR #1347: Update FFT library for new syntax requirements
  • PR #1348: Update set.dx and tests for new syntax requirements
  • #310: Prevent line comment parser from consuming # inside strings
  • #1133: Allow effects in scan and fold body functions
  • #1167: Allow redefining variables after failed REPL definitions
  • #1211: Use unsigned div/rem instructions for unsigned types
  • #1267: Move >>> and <<< to higher precedence than arrow operators
  • #1342: Add TypeScript source to cabal data-files
  • #1343: Add missing System.IO.Unsafe import for debug builds
  • #1345: Add VSpace instance for Float64 to enable negation
  • Fix FFT type inference: add explicit type annotations for butterfly_ixs
  • Fix Float64 VSpace instance: convert Float scalar to Float64

Reverted

These were attempted but reverted due to issues:

  • #1033: Handle zero base in complex pow to avoid NaN
  • #1338: Allow function types in struct fields without extra parens

Test plan

  • Verify CI parallel test execution works on Linux and macOS
  • Run FFT tests to confirm type annotations resolve inference issues
  • Confirm unsigned div/rem behaves correctly for Word8/Word32/Word64
  • Verify line comment parsing doesn't break string literals containing #
  • Test REPL variable redefinition after failed definitions

🤖 Generated with Claude Code

Detect available CPU cores and pass -j flag to make tests for parallel
execution. Supports Linux (lscpu), macOS (sysctl), with fallback to 1.

https://claude.ai/code/session_01N4W4JdwHYfmusD4PuxRqbv
…ements

- Add explicit a:Type constraints to odd_sized_palindrome and pad_to_power_of_2
- Add explicit type annotations to butterfly_ixs return values
- Add explicit index types to for loops throughout fft.dx
- Cast zero to Complex explicitly for pad_to_power_of_2 calls
- Use each instead of map in fft-tests.dx
- Add index type annotations to 2D FFT functions

https://claude.ai/code/session_01N4W4JdwHYfmusD4PuxRqbv
…equirements

- Add explicit a:Type constraints to last, first, all_except_last
- Use Fin directly in all_except_last instead of intermediate variable
- Reorder reduce arguments to match current signature
- Add type annotation to lambda in set_intersect
- Update comment syntax from -- to # in set-tests.dx

https://claude.ai/code/session_01N4W4JdwHYfmusD4PuxRqbv
The compiler couldn't synthesize the Ix instance for the return type of
butterfly_ixs when called from power_of_2_fft. Added a type alias and
explicit tuple annotation to resolve the inference.

https://claude.ai/code/session_016T3EsHh2mTDh4e8Rbt8KJH
pow(0+0i, z) returned NaN because log(0) = -inf, and multiplying
the imaginary component by -inf produced NaN via IEEE 754 rules
(0 * inf = NaN). Special-case zero base: return 0 when Re(power) > 0.

https://claude.ai/code/session_01N4W4JdwHYfmusD4PuxRqbv
…egation

Float64 was missing a VSpace instance, causing "can't synthesize a
class dictionary for: (VSpace Float64)" when using unary negation.
The neg function requires VSpace, so Float64 negation was impossible.

https://claude.ai/code/session_01N4W4JdwHYfmusD4PuxRqbv
…arrow operators

The function composition operators >>> and <<< were placed at lower
precedence than -> and =>>, causing expressions like (exp >>> sq) to
be misparsed as function application rather than composition. Move
them above arrow operators so they bind tighter, matching the design
intent documented in syntax-philosophy.md.

https://claude.ai/code/session_01N4W4JdwHYfmusD4PuxRqbv
The VSpace interface uses Float (Float32) as the scalar type, so the
Float64 instance needs f_to_f64 conversion before multiplying.

https://claude.ai/code/session_016T3EsHh2mTDh4e8Rbt8KJH
The scan and fold functions had pure-only type signatures for their
body parameters, preventing effectful operations inside them despite
the underlying run_state implementation supporting effects. Generalize
the body type to allow arbitrary effects via {|eff}.

https://claude.ai/code/session_01N4W4JdwHYfmusD4PuxRqbv
After the TypeScript switch, static/index.ts is the source file and
static/index.js is generated. Add index.ts to data-files so it's
included in source distributions.

https://claude.ai/code/session_01N4W4JdwHYfmusD4PuxRqbv
…ug builds

The DEX_DEBUG code path uses unsafePerformIO but the import was missing,
causing compilation failures when DEX_DEBUG is enabled (including CI via DEX_CI).

https://claude.ai/code/session_01N4W4JdwHYfmusD4PuxRqbv
…ned types

The compiler unconditionally emitted SDiv/SRem (signed division and
remainder) for all integer types, producing wrong results for unsigned
types like Word8/Word32/Word64. Now dispatches to UDiv/URem based on
the operand's base type.

https://claude.ai/code/session_01N4W4JdwHYfmusD4PuxRqbv
…L definitions

When a variable definition failed (e.g. due to a typo), the REPL
registered the name with a "failed" marker in the source map via
uDeclErrSourceMap. This prevented future redefinition attempts with
"variable already defined". Stop poisoning the namespace on failure
so users can correct their mistakes and redefine.

https://claude.ai/code/session_01N4W4JdwHYfmusD4PuxRqbv
…ut extra parens

The parser rejected non-parenthesized function types (A -> B) in
struct fields and data constructors with "Argument types should be
in parentheses". Now treats unparenthesized arrow LHS as an anonymous
binder, so "Int -> Int" desugars to "(_:Int) -> Int", matching user
expectations for function-typed fields.

https://claude.ai/code/session_01N4W4JdwHYfmusD4PuxRqbv
… inside strings

The lineComment parser consumed everything from # to end of line,
including when # appeared before a string delimiter (e.g. in expressions
like s = "#text"). Add notFollowedBy check so #" is not treated as a
comment start, allowing the string literal parser to handle it.

https://claude.ai/code/session_01N4W4JdwHYfmusD4PuxRqbv
@jakeuribe jakeuribe merged commit 2ed8995 into main Feb 22, 2026
2 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants