Typecheck fn calls - #79
Merged
mikucionisaau merged 7 commits intoAug 3, 2026
Merged
Conversation
…s less than param count)
checkExpression's too-few-arguments guard compared the loop index against expr.get_size() while indexing arguments with expr[i+1], so it either never fired (missing exactly one argument) or fired one iteration too late, tripping the out-of-bounds assert in Expression::operator[] first. Only reachable via query type-checking, since top-level document parsing skips TypeChecker once ExpressionBuilder has already recorded a "too few arguments" error. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
visit_variable() called checkInitialiser() but never assigned the returned Expression back to variable.init, so global/const struct initialisers with out-of-order named fields kept their raw parse-order sub-expressions instead of being reordered to match field declaration order (visit_block_statement already did this correctly for locals). Separately, checkInitialiser's array branch called itself recursively per element but never stored the result in result[i], leaving the returned LIST full of empty sub-expressions whenever an array element needed coercion/reordering (e.g. array of structs with named fields). This was masked for globals by the bug above, but corrupted local array-of-struct initialisers via visit_block_statement. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
mikucionisaau
marked this pull request as ready for review
August 3, 2026 13:04
…rrors The struct/array initialisation tests in parser_test.cpp only asserted that no errors/warnings were produced, never inspecting the resulting Variable::init expression. That meant none of them would have caught the two checkInitialiser bugs just fixed: they compared equal whether checkInitialiser's rewritten (correctly typed/reordered) result was kept or silently discarded. Add assertions that the initialiser carries the variable's exact declared type (label/const/meta/range annotations, which only appear once checkInitialiser's return value is actually used) and that each field/element holds the expected value. Verified these now fail against the pre-fix TypeChecker.cpp (13 of the strengthened cases regress) and pass against the fix. Also drops an exact duplicate "Meta field in non meta struct" test case. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Matches the existing get_templates() pattern. Lets read-only helpers take a const Document& instead of requiring mutable access just to read global declarations. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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.
Improves error reporting when fn call arguments do not match the function parameters.