1. Resolves includes to find available words from std:json and other …#31
1. Resolves includes to find available words from std:json and other …#31
Conversation
…modules 2. Registers those words with both the AST validator and typechecker 3. Shows errors for genuinely undefined words like xson-serialize 4. Clears errors when you fix them back to valid words like json-serialize The include-aware completion and diagnostics are now fully functional.
PR Review: Include-Aware LSP Completion and DiagnosticsSummaryThis PR implements a significant enhancement to the LSP server by adding include-aware completion and diagnostics. The implementation resolves includes to find available words from ✅ Strengths1. Well-Architected Design
2. Good Error Handling
3. Comprehensive Testing
4. Compiler Integration
🐛 Potential Issues1. Path Canonicalization on Non-Existent FilesLocation: let canonical = match path.canonicalize() {
Ok(p) => p,
Err(_) => {
debug!("Could not canonicalize: {:?}", path);
return;
}
};Issue: Suggestion: Consider using the non-canonical path for cycle detection if canonicalization fails, or log a more specific warning about why it failed. 2. Percent Decoding ImplementationLocation: if hex.len() == 2
&& let Ok(byte) = u8::from_str_radix(&hex, 16)
{
result.push(byte as char);Issue: This assumes single-byte characters. URIs with multibyte UTF-8 sequences (e.g., Suggestion: Consider using the let mut bytes = Vec::new();
// collect all %XX sequences
String::from_utf8_lossy(&bytes)3. Maximally Polymorphic Placeholder May Hide Type ErrorsLocation: let placeholder = Effect::new(
StackType::RowVar("ext_in".to_string()),
StackType::RowVar("ext_out".to_string()),
);Issue: When an included word's effect is Impact: Medium - may cause runtime errors for words without effect signatures
4. Missing Error Context in DiagnosticsLocation: When checking with external words, the error message from Suggestion: Enhance error messages to show available included words or at least mention include resolution. ⚡ Performance Considerations1. Re-parsing on Every ChangeLocation: self.update_document(uri.as_str(), text.clone(), file_path);Every keystroke triggers:
Impact: Could be slow for large projects with many includes Suggestion:
2. Cloning Included/Local Words on Every CompletionLocation: state.included_words.clone(),
state.local_words.clone(),Impact: Low - typically small vectors, but could add up Suggestion: Use 3. Linear Search for Stdlib PathLocation: The Impact: Very low - only called once at startup Suggestion: Current implementation is fine; nice optimization would be caching result in a 🔒 Security Considerations1. Path Traversal Risk (Low)Location: For let path = dir.join(format!("{}.seq", name));Issue: If Impact: Low - LSP context is already trusted (user's own code) Mitigation: Already somewhat protected by checking 2. No Resource Limits on Include ResolutionLocation: While there's a depth limit (10), there's no limit on total number of files or total size of included content. Impact: Low - same trust model as above Suggestion: Consider adding limits on total included files (e.g., max 100 files) to prevent pathological cases. 📊 Test CoverageGood:
Missing:
Recommendation: Add at least one integration test showing: // file1.seq: include "file2"
// file2.seq: : helper ( -- ) ;
// Verify completion shows "helper" in file1📝 Code QualityPositive:
Minor Suggestions:
🎯 Overall AssessmentQuality: ⭐⭐⭐⭐ (4/5) This is a solid, well-thought-out implementation. The architecture is clean, error handling is generally good, and the test coverage is reasonable. The main concerns are:
🚀 Recommendation✅ APPROVE with minor fixes Suggested before merge:
Nice to have:
Great work on this feature! The include-aware completion will significantly improve the developer experience. Review generated with assistance from Claude Code |
1. Fixed percent decoding for UTF-8 - Now properly handles multi-byte UTF-8 sequences like %C3%A9 → é by collecting bytes and decoding with from_utf8_lossy 2. Removed PLAN.md - Planning notes shouldn't be in production code 3. Added TODO comment - Documented the polymorphic placeholder limitation in diagnostics.rs:54-58 for future consideration The other suggestions (debouncing, Arc<Vec<>>, tracing spans) are nice-to-have optimizations that can be done later if performance becomes an issue.
PR Review #31: Include-Aware LSP Completion and DiagnosticsOverviewThis PR successfully implements include-aware completion and diagnostics for the LSP server, addressing the previous feedback. The implementation properly resolves includes, registers external words with the validator and typechecker, and provides context-aware completions. ✅ Excellent Work1. Previous Feedback Addressed
2. Clean Architecture
3. Robust Error Handling
4. Comprehensive Testing
|
🔍 Issues Found1. Critical: Row Variable Name Collision RiskLocation: compiler/src/typechecker.rs:46-49 All external words without effects get the same row variable names "ext_in" and "ext_out". If multiple such words are used in the same program, the typechecker will unify their effects incorrectly. Fix: Use fresh variables for each external word: let placeholder = Effect::new(
StackType::RowVar(format!("ext_in_{}", name)),
StackType::RowVar(format!("ext_out_{}", name)),
);Impact: High - can cause type errors to go undetected 2. Bug: Incorrect String Detection in CommentsLocation: completion.rs:77-91 The hash detection logic can incorrectly identify comments. After a string like "hello # world", a real comment may be treated as code because rfind finds the # inside the string. Test case that would fail: assert_eq!(detect_context("\"#\" # comment"), ContextType::InComment);Impact: Medium - autocomplete appears when it shouldnt 3. Bug: Paren Counting Includes StringsLocation: completion.rs:104-110 Counts ALL parens including those in strings, causing incorrect stack effect detection. Impact: Medium - wrong completions in edge cases |
4. Performance: Cloning on Every CompletionLocation: main.rs:234-248 Every completion request clones potentially large Vec and Vec. Consider using Arc<Vec<>> as suggested in previous review. Impact: Low-Medium - completion requests are frequent 5. Inconsistency: cfg(test) on Public FunctionLocation: diagnostics.rs:10-12 check_document is pub but only available in tests - confusing API. Either make it pub(crate) or remove cfg(test). ⚡ Performance & SecurityPerformance:
Security:
📋 Test CoverageStrengths: Context detection, URI parsing, include resolution well tested Gaps:
|
🎯 RecommendationsMust Fix (Before Merge):
Should Fix (Soon):
Nice to Have:
✨ Overall AssessmentQuality: 8/10 - Well-architected, addresses previous feedback, good test coverage Readiness: Almost ready - needs critical bug fixes before merge Impact: High - Significantly improves LSP experience with include-aware features This is excellent work that substantially improves the developer experience. The architecture is sound and the implementation is clean. Once the critical type variable collision is fixed and the context detection bugs are addressed, this will be ready to merge. Great job on addressing the previous feedback, especially the UTF-8 decoding fix! 🎉 |
Pull Request Review - PR 31SummaryThis PR implements include-aware completions and diagnostics for the LSP server. It adds the ability to resolve include statements, extract word definitions from included modules, and use them for both autocompletion and error checking. This is a significant enhancement to the developer experience. Code Quality and Best Practices - ExcellentStrengths
Minor Concerns
Potential Bugs and IssuesCritical Issues
Medium Priority Issues
Performance ConsiderationsGood Practices
Optimizations to Consider
Security Concerns - Low Risk
Test Coverage - Very GoodExcellent Coverage
Missing Tests
RecommendationsMust Fix Before Merge
Should Fix Soon
Nice to Have
Overall Assessment - 4.5/5 StarsThis is a high-quality PR that significantly improves the LSP functionality. The code is well-structured, well-tested, and follows good practices. The include resolution logic is sound with proper cycle detection. Main concerns:
With the sed fix and type safety consideration addressed, this PR is ready to merge. The remaining issues are minor optimizations. Great work on this enhancement! The context-aware completions and include-aware diagnostics will greatly improve the developer experience. Review generated with Claude Code |
Fixed: 1. sed command in release workflow - Now targets specifically the line after [workspace.package] instead of replacing the first version line found 2. Paren counting in strings - New count_unmatched_parens() function ignores parens inside string literals 3. Added tests - For parens inside strings The comment detection was already correct (lines 82-91 check if # is inside a string before treating it as a comment), so no change was needed there.
…ckage] section (0.3.0 → 0.4.0) and leaves everything else untouched. The type safety issue (polymorphic placeholder) was already documented with a TODO comment in diagnostics.rs:54-58 from the earlier fix. That's the "documented" part the review refers to.
PR Review: Include-aware LSP Completions and DiagnosticsOverviewThis PR adds significant LSP functionality by implementing include-aware completions and diagnostics. ✅ Strengths
|
…modules
The include-aware completion and diagnostics are now fully functional.