Type checker and interpreter refactors#85
Merged
figgleforth merged 20 commits intomainfrom Apr 7, 2026
Merged
Conversation
- Changed `@cd` directive to use sibling_scopes - Renamed check_dot_access_permissions to check_dot_access_permissions! because it raises - Improved bin/ore, fixing the broken bin/ore usage example in main readme - Removed destructive assignment scope oddity
Removed unnecessary `cd_scopes` attr
Renamed Server_Runner to User_Server.
Method for collecting routes from an instance was overwriting Interpreter's routes collection by mistake.
Reduce duplicate code
Removed code that duplicates Interpreter#interp_func_call
- No need to pass routes, leftover copypaste hiccup from runtime refactor
- Request and Response objects had complex inits in two locations, factored out - Removed Request and Response #initillize code since that is now handled in the now factored out builders - Fix frozen string literal warning by thawing +str
`Return < Scope` is gone, replaced with `Return = Data.define(:value)`. All tests pass.
Cleaning up unused code
There was no need for a temporary interpreter object here becaue #load_file_into_scope saves and restores state of the interpreter.
Document #load_file_into_scope
Factored out shared code in #interp_conditional
Documenting
Ore::Dictionary access is now consistent with strings and symbols, and with dot access.
x = { :abc = 123 }
x.abc
x['abc']
x[:abc]
All return value 123.
Tests pass.
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.
Type Checker
The existing
Type_Checkerstub has been fleshed out into a real static analysis pass that runs before interpretation. Itchecks:
x: String = 123raisesType_Mismatchgo { x: Number = 'bad'; x }is caught at compile timeThe checker does full AST traversal (functions, types, conditionals, loops, directives, etc.), and silently skips anything it can't statically infer (e.g., identifiers with unknown types). A new type_checker_test.rb covers 30+ cases across happy paths and mismatches at the top level, inside functions, types, and conditionals.
A new
Type_Mismatch < Type_Checking_Failederror carries the declared and inferred types. Type_Checking_Failed now holds the list of errors it accumulated.Interpreter Refactors
Several cleanup passes landed alongside the type checker:
#find_ruby_class_for_type— replaced two near-identical blocks of Ruby class resolution logic with a single helper#track_static_declaration— deduplicated three copies of the./scope operator check into one method#check_dot_access_permissions!— renamed with!to signal it raises@cddirective — now non-destructive: wraps the target in aTemporary < Scopescope with the target as a sibling, rather than pushing the target directly onto the stack (eliminates the cd_scopes set)catch :skipblocksOre::Returnextracted to its own file, no longer subclass ofScopeServer_Runner→User_Serverbuild_ore_requestandbuild_ore_responsehelpersinterp_route_handlerinstead of manual scope push/pop.bin/oreDefault invocation (
ore <file>) now callsinterp_filedirectly instead of hot-reload. Hot-reload moved to an explicitrunsubcommand.