Add typed slice support and expand coverage#14
Merged
Conversation
There was a problem hiding this comment.
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.
16d5fd9 to
70e91fa
Compare
70e91fa to
4f45d42
Compare
There was a problem hiding this comment.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This follow-up PR finishes the remaining review-driven fixes and adds targeted regression coverage.
Summary:
in,contains, andwherewhere%runtime results consistent with folded expressionsValidation:
go test ./...