-
Notifications
You must be signed in to change notification settings - Fork 370
Fix transpiler validation and improve error messages #2514
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
sensei-hacker
merged 5 commits into
iNavFlight:maintenance-9.x
from
sensei-hacker:fix-transpiler-validation
Jan 13, 2026
Merged
Fix transpiler validation and improve error messages #2514
sensei-hacker
merged 5 commits into
iNavFlight:maintenance-9.x
from
sensei-hacker:fix-transpiler-validation
Jan 13, 2026
Conversation
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
This commit fixes three issues in the JavaScript Programming tab:
1. **Fix silent code dropping for invalid function calls**
- Previously, code like `inav.override.flightAxis(180);` was silently
discarded without any error message
- Now generates clear error: "Cannot call 'X' as a function"
- Added extractCalleeNameForError() helper to show full call path
- Location: js/transpiler/transpiler/parser.js
2. **Add comprehensive intermediate object detection**
- Detects when users try to use objects as if they were properties
- Catches: assignments, function calls, expressions, comparisons
- Examples caught:
* `inav.override.flightAxis.yaw = 180` (missing .angle)
* `gvar[0] = inav.flight + 1` (flight is an object)
* `inav.override.vtx(3)` (vtx is object, not function)
- Provides helpful suggestions showing available properties
- Locations:
* js/transpiler/transpiler/property_access_checker.js
* js/transpiler/transpiler/analyzer.js
3. **Fix missing i18n text in JavaScript Programming tab header**
- Added i18n.localize() calls in tab initialization
- Added CSS to fix paragraph spacing (margin-bottom: 10px)
- Locations:
* tabs/javascript_programming.js (lines 84, 91)
* tabs/javascript_programming.html (line 217-219)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
- Changed addError to addWarning with type 'error' in parser - Made transpile() fail when parser errors are present - Prevents silent code dropping from succeeding compilation
This commit completes the transpiler validation improvements by: 1. Enhanced intermediate object detection (property_access_checker.js): - Now uses raw API definitions instead of processed structure - Simplified logic per user suggestion: just check typeof === 'object' - Catches 2-level objects (e.g., inav.override.vtx) - Catches 3-level objects (e.g., inav.override.flightAxis.yaw) - Catches category-only access (e.g., inav.flight) 2. Improved error messages (analyzer.js): - Shows available properties for intermediate objects - Differentiates simple vs deeply nested objects - Provides actionable suggestions 3. Comprehensive test coverage: - test_examples.mjs: All 22 examples still compile (no regressions) - test_validation_fixes.mjs: 8/8 validation tests pass All invalid code now generates helpful error messages instead of: - Being silently dropped - Failing later in codegen with cryptic messages - Passing through to generate invalid logic conditions 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Contributor
PR Compliance Guide 🔍All compliance sections have been disabled in the configurations. |
Address Qodo code review feedback: check result.warnings.errors instead of result.errors for semantic/validation errors.
Contributor
PR Compliance Guide 🔍All compliance sections have been disabled in the configurations. |
…y key Prevents generating error suggestions containing 'undefined' when nested.properties is an empty object. Addresses qodo-merge-pro bot suggestion on PR iNavFlight#2514. Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
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.
User description
Summary
Improves JavaScript Programming transpiler validation to catch invalid code with helpful error messages instead of silently dropping code or failing with cryptic messages.
Changes
Validation Improvements:
inav.override.flightAxis(180))inav.flightwithout a property)Error Message Enhancements:
Test Coverage:
test_examples.mjs- regression test for all 22 examplestest_validation_fixes.mjs- tests for new validation featuresi18n Fixes:
Files Changed
js/transpiler/transpiler/parser.js- Invalid function call detectionjs/transpiler/transpiler/analyzer.js- Improved error messages for assignmentsjs/transpiler/transpiler/property_access_checker.js- Enhanced intermediate object detectionjs/transpiler/transpiler/index.js- Fail transpilation on parser errorstabs/javascript_programming.js&.html- i18n display fixeslocale/en/messages.json- i18n texttest_examples.mjs&test_validation_fixes.mjs- New test filesTesting
Examples
Before:
inav.override.vtx = 3;silently fails or shows "Cannot assign to 'inav.override.vtx'. Not a valid INAV writable property."After: Clear error: "Cannot assign to 'inav.override.vtx' - it's an object, not a property. Available properties: inav.override.vtx.power, inav.override.vtx.band, inav.override.vtx.channel"
PR Type
Bug fix, Enhancement
Description
This description is generated by an AI tool. It may have inaccuracies
Detects invalid function calls and intermediate object usage with clear error messages instead of silently dropping code
Improves error messages by showing available properties for nested objects and suggesting correct access patterns
Fails transpilation when parser errors occur, preventing invalid code from compiling
Adds comprehensive test coverage with regression tests for all 22 examples and 8 validation scenarios
Fixes missing i18n localization in JavaScript Programming tab and improves paragraph spacing
Diagram Walkthrough
File Walkthrough
4 files
Detect invalid function calls with error reportingFail transpilation when parser errors presentAdd i18n localization to tab initializationFix paragraph spacing in warning text2 files
Improve error messages for invalid assignmentsDetect intermediate objects and nested property validation1 files
Update JavaScript beta warning message text2 files
Add regression test for all 22 examplesAdd validation test suite for error detection