Skip to content

Look up what a script base declares before taking a name for inherited - #52

Open
Tutez64 wants to merge 1 commit into
MeguminBOT:mainfrom
Tutez64:bugfix/cppia-script-base-member
Open

Tutez64 wants to merge 1 commit into
MeguminBOT:mainfrom
Tutez64:bugfix/cppia-script-base-member

Conversation

@Tutez64

@Tutez64 Tutez64 commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

Under a script base, a name the emitter could not place is no longer compiled to a field of this.

inheritedMember answered yes for any name as soon as the base was a script class. That check runs before worldType and the host globals, so in such a class:

  • a host type named without an import (HostBase) compiled to this.HostBase;
  • the package heading a dotted path (haxe in haxe.ds.StringMap) compiled to this.haxe.

Both read null at run time, silently, where the interpreter gives the right value. A typo did the same instead of refusing the module.

The emitter now records each batch class's own instance members at declare, and walks the chain: each script base's members first, then the first host base through reflection, as it already did when the base was a host class. An unknown script base still answers yes, as before. The walk stops after 64 levels so a malformed cycle cannot hang it.

Under a script base Before After
Type.getClassName(HostBase), no import compiled, null compiled, HostBase
Type.getClassName(haxe.ds.StringMap) compiled, null refused, interpreted, haxe.ds.StringMap (compiled with #51)
a member of the script base (hello(), tag) compiled, right compiled, right

Tests

  • Two corpus cases. Without the fix both fail in the cppia suite: cppia gave null,hi,t, interpreter gave HostBase,hi,t and cppia gave null, interpreter gave haxe.ds.StringMap.
  • test/run.sh eval cpp: 421 / 421 / 452. Conformance columns are unchanged apart from the two new rows.
  • Flixel sandbox (flixel, openfl, lime, plain, JIT on and off): same modules compiled, same byte counts, same two left interpreted (Playground, Shapes) as the baseline.

Under a script base, any name the emitter could not place was compiled to a
field of `this`: a host type named without an import, or the package heading a
dotted type path, read null at run time instead of resolving or refusing the
module. The chain is now walked through each script base's own members, then
the first host base's, as for a host base alone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant