Skip to content

Add typed slice support and expand coverage#14

Merged
danielgtaylor merged 2 commits into
mainfrom
codex/review-findings-followups
Apr 23, 2026
Merged

Add typed slice support and expand coverage#14
danielgtaylor merged 2 commits into
mainfrom
codex/review-findings-followups

Conversation

@danielgtaylor
Copy link
Copy Markdown
Owner

This follow-up PR finishes the remaining review-driven fixes and adds targeted regression coverage.

Summary:

  • add direct support for common typed slices and reflection-backed arrays/slices across indexing, slicing, length, concat, in, contains, and where
  • align typechecking with runtime for empty arrays and representative objects in where
  • make lexer offsets and pretty errors rune-based so Unicode caret placement stays correct
  • normalize nested numeric container equality and keep % runtime results consistent with folded expressions
  • document numeric coercion and typed slice behavior in the README
  • add focused tests for typed slices, reflection-backed arrays, truthiness, numeric conversions, helper formatting, and rune-aware errors

Validation:

  • go test ./...
  • package coverage raised to 80.0%

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends the expression engine to handle common typed Go slices and reflection-backed arrays/slices throughout evaluation and typechecking, while also making error positioning Unicode-safe (rune-based) and adding regression tests/docs to lock in the behavior.

Changes:

  • Add typed slice + reflection-backed array/slice support across indexing/slicing/length/concat and operators like in, contains, where.
  • Switch lexer/token offsets and pretty error caret placement to rune-based positions for correct Unicode alignment.
  • Improve numeric/container equality behavior and % runtime result consistency, plus add targeted tests and README documentation.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
typecheck.go Treat empty arrays/objects in where as array[unknown] to match runtime behavior.
conversions.go Add slice/array helpers (sliceLen, sliceItem, sliceRange, iterateSlice, etc.) and recursive deep equality normalization.
interpreter.go Use new slice helpers for bounds checks, slicing/indexing, concat, in/contains, where, and make % return float64.
lexer.go Track rune positions (runePos) and compute token offsets/lengths in runes.
error.go Make Pretty() build rune-accurate caret lines and update docs to rune-based offsets/lengths.
README.md Document rune-based offsets, numeric coercion for typed functions, and typed slice/reflection behavior.
lexer_test.go Add tests for rune-based offsets/pretty errors plus token/node formatting and error accessors.
interpreter_test.go Add tests for typed slices, reflection-backed arrays/slices, truthiness, numeric conversions, empty where inputs, and nested numeric equality.
conversions_test.go Add focused unit tests for toNumber, generic slice append/concat helpers, and toBool.
review.md Track review status/notes and residual gaps.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread typecheck.go Outdated
Comment thread lexer.go
Comment thread review.md Outdated
@danielgtaylor danielgtaylor force-pushed the codex/review-findings-followups branch 3 times, most recently from 16d5fd9 to 70e91fa Compare April 22, 2026 21:12
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread conversions.go
@danielgtaylor danielgtaylor merged commit 36d9075 into main Apr 23, 2026
1 check passed
@danielgtaylor danielgtaylor deleted the codex/review-findings-followups branch April 23, 2026 00:10
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