fix: collect expression symbols with symbol? - #60
Open
felipeofdev-ai wants to merge 1 commit into
Open
Conversation
Filter tree leaves with symbol? instead of (complement seqable?) so non-symbol atoms are never treated as ?-inputs. Fixes nubank#59 Signed-off-by: Felipe Fernandes <felipe.of.dev@gmail.com>
There was a problem hiding this comment.
Pull request overview
This PR refines nodely.syntax’s ?-input discovery by having expression-symbols collect only symbols, making intent clearer and avoiding non-symbol atoms being considered during traversal.
Changes:
- Update
expression-symbolsto filter withsymbol?instead of(complement seqable?). - Add a docstring explaining why
symbol?is used. - Add tests around
>leafinput discovery to prevent non-symbol atoms from being treated as inputs.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/nodely/syntax.clj |
Switches leaf collection to symbol? and documents the rationale for input discovery. |
test/nodely/syntax_test.clj |
Adds coverage around >leaf input detection for non-symbol atoms in expressions. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+225
to
+230
| (testing "numbers and keywords in an expression do not become inputs" | ||
| (is (match? #::data{:type :leaf :inputs #{:x} :fn ifn?} | ||
| (>leaf (+ ?x 1 :not-an-input))))) | ||
| (testing "only `?`-prefixed symbols become inputs" | ||
| (is (match? #::data{:type :leaf :inputs #{:y} :fn ifn?} | ||
| (>leaf (str ?y "suffix")))))) |
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.
Summary
expression-symbolsto filter withsymbol?instead of(complement seqable?).>leafexpressions do not become inputs.Why
?-input discovery only needs symbols. Filtering non-seqable leaves also kept numbers, keywords, and strings in the candidate set until a later string prefix check —symbol?answers issue #59 directly and makes the intent obvious.Fixes #59
Test plan
lein test nodely.syntax-test(0 failures)— Felipe Fernandes · Systems & Agentic AI Engineer
https://github.com/felipeofdev-ai · https://felipeofdev-ai.github.io/
Made with Cursor