feat(type-checker): add undefined-identifier, arity, and arg-type dia…#35
Merged
Conversation
…gnostics Closes the four skipped diagnostics in tests/error-handling.test.ts: - Undefined-variable detection via inferIdentifierType with a builtin value seed set (чоп, console, Math, Array, etc.) so existing .som examples keep compiling cleanly. - Argument count and argument type validation in inferCallType, with Type.paramTypes / paramNames / paramOptional populated by checkFunctionDeclaration and hoistFunctionDeclaration. Optional params (name?: type) are correctly excluded from the required count. - Recursion into function bodies in checkFunctionDeclaration so errors in nested functions are reported. ExpressionStatement and ExportDeclaration cases added to checkStatement. - compile() now surfaces parser.getErrors(). In the default mode they are warnings; strict mode promotes them to errors. This lets the typo-keyword test see the "Unexpected token" diagnostic without breaking audit:examples for files with recoverable parse issues. Incidental fixes uncovered by recursive body walking: - Lexer now skips /* ... */ block comments. - isAssignable check skips 'unknown' inferred types to avoid cascading false positives for expressions whose inference isn't wired yet. - 17-export-patterns.som: default-parameter syntax replaced with optional parameter + in-body default (parser support for default param values remains out of scope here). - 09-interfaces.som: type alias Ҳолат renamed to Статус to avoid collision with the reserved keyword ҳолат.
|
✅ Tests completed on Node.js 20.x: success |
Replaces English JS method names in .som example files with their
Tajik equivalents that already exist in codegen's builtinMappings:
.toUpperCase() -> .калон()
.toLowerCase() -> .хурд()
.length -> .дарозӣ
.push() -> .илова()
.filter() -> .филтр()
.pop() -> .баровардан()
.slice() -> .буридан()
.map() -> .харита()
.forEach() -> .бароиҲар()
.join() -> .пайвастКардан()
.split() -> .ҷудокунӣ()
.indexOf() -> .индекси()
.includes() -> .дорад()
.repeat() -> .такрор()
.sort() -> .тартиб()
.toString() -> .баСатр()
.trim() -> .тозаКардан()
.startsWith() -> .оғозБо()
.endsWith() -> .анҷомБо()
.replace() -> .ҷойгузин()
.concat() -> .пайвастан()
Adds Tajik aliases for Map / Set methods that were previously only
accessible by their JS name:
.get() -> .бозгирифтан() (тадж: retrieve; avoids a conflict
with the existing .гирифтан->.catch
Promise alias)
.set() -> .гузоштан()
.has() -> .дорадКалид()
.size -> .ҳаҷм
.delete() -> .нобудКардан()
Replaces the verbose тағйирёбанда keyword with its short-form alias
тағ everywhere in examples so the Tajik surface of the language
reads uniformly across files.
|
✅ Tests completed on Node.js 20.x: success |
8b758d1 to
882bfee
Compare
|
✅ Tests completed on Node.js 20.x: success |
Extract parser-error routing, type-check stage, and code emission into small helpers so compileInternal reads as a linear pipeline. Behaviour is unchanged — same tests, same audit. The sonar complexity lint on compileInternal (16 > 15) is cleared as a side effect.
|
|
✅ Tests completed on Node.js 20.x: success |
ggulpari
approved these changes
Apr 22, 2026
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.



…gnostics
Closes the four skipped diagnostics in tests/error-handling.test.ts:
Incidental fixes uncovered by recursive body walking:
🎉 Pull Request
Description
Type of Change
to not work as expected)
Related Issue
Fixes #(issue number)
Changes Made
Testing
npm test)npm run lint)npm run type-check)Checklist
Additional Context
📋 License Information
SomonScript is open source software licensed under the MIT License.
By submitting this pull request, you agree that your contributions will be
licensed under the MIT License.
For contribution guidelines, please review:
guidelines
Thank you for contributing to SomonScript! 🚀