Fix #150: Extend analyze_pattern for vector destructuring patterns#151
Fix #150: Extend analyze_pattern for vector destructuring patterns#151andreasronge merged 4 commits intomainfrom
Conversation
Implements Phase 1 of the Function Parameter Destructuring epic (#147): - Adds support for vector patterns [{:vector, elements}] in analyze_pattern - Implements analyze_pattern_list helper to recursively process pattern elements - Updates analyze_fn_params to use analyze_pattern instead of simple symbol validation - Enables sequential destructuring patterns like [a b] in function parameters This change is part of the analyzer phase only. Pattern evaluation support (Phase 2) will be implemented separately with evaluator updates. Also includes minimal evaluator changes to handle pattern-based closures: - Updates closure creation to store patterns directly - Implements match_pattern for sequential patterns - Properly handles destructuring errors at runtime Tests updated: - analyze_test.exs: Updated fn param test from rejection to acceptance - eval_test.exs: Updated closure test to match pattern-based storage - e2e_test.exs: Updated to test runtime error handling Fixes #150 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
PR Review: Fix #150: Extend analyze_pattern for vector destructuring patternsSummaryThis PR implements Phase 1 of the Function Parameter Destructuring epic (#147) by extending the analyzer to support vector destructuring patterns in function parameters. The implementation follows the spec closely in What's Good
Issues (Must Fix)
Suggestions (Optional)
SecurityNo concerns - this PR modifies only internal DSL processing with no external I/O or user-controlled code paths. DocumentationThe spec (Section 5) explicitly requires documentation updates that were not included:
VerdictRequest Changes - The implementation is solid but the PR is incomplete per the spec requirements. The documentation updates and at least basic success tests are required before merge to ensure:
All fixes are mechanical and follow patterns already established in the spec. |
|
@claude please fix these issues from PR review: Issue 1: Missing documentation updates in docs/ptc-lisp-llm-guide.md
Issue 2: Missing E2E success tests in test/ptc_runner/lisp/ptc_lisp_e2e_test.exs
Issue 3: Type spec inconsistency in lib/ptc_runner/lisp/eval.ex:24
Issue 4: Missing error type in lib/ptc_runner/lisp/eval.ex:26-33
Please fix ALL issues above in a SINGLE commit. |
Auto-Triage SummaryDecisions Made
Status
ReasoningAll four issues are:
The reviewer noted this as "Request Changes" because the PR is incomplete per spec requirements. All fixes follow patterns already established in the spec and codebase. |
…and tests
- Update docs/ptc-lisp-llm-guide.md line 213 to show all three fn forms (simple, vector, and map destructuring)
- Remove fn destructuring workaround row from Common Mistakes table (line 317)
- Add E2E success tests for vector pattern destructuring in fn params
- Add E2E success tests for map pattern destructuring in fn params
- Add E2E test for vector pattern ignoring extra elements
- Fix closure type spec from [atom()] to [CoreAST.pattern()] in eval.ex:24
- Add missing {:destructure_error, String.t()} to runtime_error type in eval.ex:26-33
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Fix Complete ✅All four issues from the PR review have been fixed in a single commit: Issue 1: Documentation Updates
Issue 2: E2E Success Tests
Issue 3: Type Spec Fix
Issue 4: Missing Error Type
Testing
Commit: cb7720d |
PR Review: Fix #150 - Extend analyze_pattern for vector destructuring patternsSummaryThis PR implements Phase 1 of the Function Parameter Destructuring epic (#147) by extending the analyzer and evaluator to support vector (sequential) destructuring patterns in function parameters. The implementation correctly follows the spec in What's Good
Issues (Must Fix)
Suggestions (Optional)
SecurityNo concerns. This change is entirely internal to the Lisp interpreter and doesn't affect sandboxing, resource limits, or external interfaces. DocumentationThe PR correctly updates VerdictRequest Changes - The stale documentation statements at lines 209 and 328 directly contradict the new feature and will cause LLM confusion. These are mechanical fixes following the same pattern as the other documentation updates in this PR. 🤖 Generated with Claude Code |
|
@claude please fix these issues from PR review: Issue 1: Stale documentation contradicting new feature Issue 2: Missing test for insufficient elements error Please fix ALL issues above in a SINGLE commit. |
Auto-Triage SummaryDecisions Made
Status
ReasoningIssue 1 & 2 - FIX_NOW:
Issue 3 - DEFER_ISSUE:
|
…nt elements test Issue 1: Stale documentation contradicting new feature - Line 209: Removed parenthetical "(ONLY in let, NOT in fn params)" from map destructuring comment - Line 328: Removed bullet point constraining destructuring to let only - Lines 213-215 correctly document fn parameter destructuring; these removals eliminate contradictions Issue 2: Missing test for insufficient elements error - Added test case verifying ((fn [[a b c]] a) [1 2]) returns destructure_error - Error message correctly indicates "expected at least 3 elements, got 2" - Fulfills spec requirement (Section 4.2 lines 326-328) All 936 tests pass. Code formatting and Credo checks clean. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Fix Complete ✅Both issues from the PR review have been fixed in a single commit (9afe9ea): Issue 1: Stale Documentation
Issue 2: Missing Error Test
Verification
Ready to merge! |
PR Review: Fix #150: Extend analyze_pattern for vector destructuring patternsSummaryThis PR implements Phase 1 of the Function Parameter Destructuring epic (#147) by extending the analyzer and evaluator to support vector (sequential) destructuring patterns in function parameters. The implementation follows the spec in What's Good
Issues (Must Fix)
Suggestions (Optional)
SecurityNo concerns - internal DSL changes with no external interfaces affected. Documentation
VerdictRequest Changes - The specification document at 🤖 Generated with Claude Code |
|
@claude please fix this issue from PR review: Issue 1: Stale documentation in specificationLocation:
Please fix this in a SINGLE commit. |
Auto-Triage Summary (Cycle 2 of 3)Decisions Made
Status
ReasoningIssue 1 - FIX_NOW:
Issue 2 - IGNORE:
|
…nt elements test - Update Section 13.2 in ptc-lisp-specification.md to document fn parameter destructuring - Add examples showing vector and map destructuring in fn params (lines 1356-1357) - Remove the "No destructuring in parameters" restriction (was line 1361) - Replace destructuring workaround example with direct destructuring syntax - Documentation now matches the LLM guide and implemented feature 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Fix Complete ✅Documentation update for PR #151 has been completed and committed. Issue Fixed: Stale documentation in specificationFile: Changes:
Section 13.2 now accurately documents that: (fn [x] body) ; single argument
(fn [a b] body) ; multiple arguments
(fn [[a b]] body) ; vector destructuring in params
(fn [{:keys [x]}] body) ; map destructuring in paramsAnd the example shows the proper pattern: ;; Destructuring in fn params (now supported)
(mapv (fn [{:keys [name age]}] {:name name :years age}) users)Verification
Commit: d23f3f8 |
PR Review: Fix #150 - Extend analyze_pattern for vector destructuring patternsSummaryThis PR successfully implements Phase 1 of the Function Parameter Destructuring epic (#147), enabling vector destructuring patterns in anonymous function parameters. The implementation closely follows the specification in What's Good
Issues (Must Fix)None identified. The implementation is complete and matches the specification. Suggestions (Optional)
SecurityNo concerns. The changes are internal to the analyzer and evaluator with no external input handling changes. Documentation✅ All documentation updated correctly:
VerdictApprove. The implementation is correct, follows the specification, has good test coverage, and documentation is properly updated. The optional suggestions are nice-to-haves for future work. 🤖 Generated with Claude Code |
Auto-Triage: Max Cycles ReachedThis PR has gone through 3 triage cycles (review → triage → fix → review...). What this means:
Next steps for a human:
This is an automated message from the auto-triage workflow. |
Summary
Implements Phase 1 of the Function Parameter Destructuring epic (#147) by extending the analyzer to support vector (sequential) destructuring patterns in function parameters.
Changes:
analyze_pattern_listhelper to recursively process pattern elementsanalyze_patternto handle{:vector, elements}AST nodesanalyze_fn_paramsto useanalyze_patterninstead of rejecting all non-symbol parameters[a b]in anonymous function parametersEvaluator Changes:
match_patternsupport for sequential patternsTests Updated:
analyze_test.exs: Changed fn param test from expecting rejection to verifying pattern acceptanceeval_test.exs: Updated closure creation test to verify pattern storagee2e_test.exs: Updated error case to test runtime destructuring errorsTest Plan
✅ All 932 tests pass
✅ Credo quality checks pass
✅ Precommit hooks pass
Existing tests validate:
(fn [[a b]] a)→{:fn, [{:destructure, {:seq, [...]}}], ...}(fn [{:keys [x]}] x)→ still works correctly(fn [x] x)→ still works correctlyFixes #150
🤖 Generated with Claude Code