Commit b14d5538
b14d5538273dMerged
Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 4 files · +2 added · ~2 modified
Description
fix(codegen,build): poly-recv dispatch includes subclasses of observed types
16a559b's poly-recv dispatch narrow set, refined by
poly_dispatch_narrow_class_set + poly_dispatch_class_in_set,
only allowed cidxes that exactly matched the observed obj_
entries. When an ivar is written via a typed setter
(def set_x(f); @x = f; end where f's declared type is the
base class) but the actual runtime value is a subclass
instance, the subclass's cidx was filtered out and the
dispatch loop never emitted its arm. Effect on tep
(framework using App.set_before(SubFilter.new)): the
@before_filter.before(req, res) callsite only generated the
Tep::Filter base arm, the subclass override never fired, and
filter mutations (response.headers[k] = v) were silently
elided.
Two pieces:
-
compiler_helpers.rb: poly_dispatch_class_in_set now also accepts ci when cls_is_descendant(ci, ancestor_ci) is true for any class in the observed set. The descendant walk already exists; the filter just wasn't consulting it.
-
Makefile: build/{analyze,codegen}.ast now properly depend on $(NODE_TABLE_LOADER_STAMP) and $(COMPILER_HELPERS_STAMP). spinel_parse inlines
require_relativecontent into the parsed AST, so a change in either helper file must re-parse the host source. My #620 Makefile split missed this transitive dep; the staleness masked the codegen fix until I noticed the binary kept emitting the pre-fix dispatch shape on a fresh build.
Tep's TestFilters / TestSecurity / TestModular / TestMultiFilters / TestMustache / TestErbIvars / TestStatic suites — 13 of the 15 cases listed in #616 — now pass. Spinel test suite stays at 592/592, bootstrap fixpoint clean, optcarrot checksum unchanged.
Fixes #616
Co-Authored-By: Claude Opus 4.7 [email protected]
Details
- Commit
- b14d5538273d
- Parent
- fb91e06f7aa9
MakefilemodifiedView file
# AST while later steps used the fresh one. The bid mismatch then# corrupted scope tables in the bootstrap fixpoint output. See #620.build/analyze.ast: $(ANALYZE_STAMP) spinel_parse$(EXE)build/analyze.ast: $(ANALYZE_STAMP) $(NODE_TABLE_LOADER_STAMP) $(COMPILER_HELPERS_STAMP) spinel_parse$(EXE) ./spinel_parse$(EXE) spinel_analyze.rb build/analyze.astbuild/codegen.ast: $(CODEGEN_STAMP) spinel_parse$(EXE)build/codegen.ast: $(CODEGEN_STAMP) $(NODE_TABLE_LOADER_STAMP) $(COMPILER_HELPERS_STAMP) spinel_parse$(EXE) ./spinel_parse$(EXE) spinel_codegen.rb build/codegen.astbuild/analyze.ir: build/analyze.ast $(ANALYZE_STAMP) $(NODE_TABLE_LOADER_STAMP) $(COMPILER_HELPERS_STAMP)compiler_helpers.rbmodifiedView file
Loading diff…
test/poly_recv_dispatch_includes_subclasses.rbaddedView file
Loading diff…
test/poly_recv_dispatch_includes_subclasses.rb.expectedaddedView file
Loading diff…