You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Two related anti-patterns produce silent-wrong-code bugs:
1. Silent-default dispatch (~15 functions)
Functions that map TS types → LLVM types use if/else chains ending with return "i8*" as a silent default. When a new type variant is added, these functions silently return a wrong pointer type instead of crashing.
Problem
Two related anti-patterns produce silent-wrong-code bugs:
1. Silent-default dispatch (~15 functions)
Functions that map TS types → LLVM types use if/else chains ending with
return "i8*"as a silent default. When a new type variant is added, these functions silently return a wrong pointer type instead of crashing.Files with
return "i8*"fallthrough defaults:src/codegen/types/objects/class.ts—fieldToLlvmType,methodReturnTypeToLlvm,fieldTypeToLlvm,fieldTypeToLlvmPrimitivesrc/codegen/expressions/access/member.ts—resolveFieldLlvmTypesrc/codegen/expressions/calls.ts— field type resolutionsrc/codegen/statements/control-flow.ts— switch discriminant type resolutionsrc/codegen/types/interface-struct-generator.ts— interface field type mappingsrc/codegen/infrastructure/generator-context.ts— type fallbackFix: Convert all dispatch to
switch+throwon default.2. Raw
endsWith("[]")array type checksScattered inline string checks like
if (t.endsWith("[]"))that manually re-derive whether something is a number/string/boolean/object array.Fix: Replace with
classifyArray()→ArrayKindenum +isAnyArrayTsType()guard checks.Progress
Guard checks (endsWith → isAnyArrayTsType) — boolean guards only
for-of.ts(10),property-handlers.ts(4),llvm-generator.ts(1),class.ts methodReturnTypeToLlvm/fieldTypeToLlvm(3)member.ts(14),variable-allocator.ts(4),type-inference.ts(6),array-allocator.ts(4),map-allocator.ts(2),owner-resolver.ts(1),class-allocator.ts(1),class-dispatch.ts(1),for-of.ts(1),json.ts(1)Type-mapping sites (endsWith → classifyArray+arrayKindToLlvm) — changes return values
class.ts methodReturnTypeToLlvm— exact equivalentclass.ts fieldTypeToLlvm— exact equivalentclass.ts fieldToLlvmType(2 sites) — has latent ordering bug, behavioral changecalls.ts getFieldLlvmType— behavioral change (object[] was %Array*, should be %ObjectArray*)member.ts resolveFieldLlvmType(2 sites) — behavioral changemember.ts(4 type-map sites) — behavioral changellvm-generator.ts(2 sites) — behavioral changeSilent-default dispatch — not started
class.ts fieldToLlvmType/fieldTypeToLlvmPrimitivemember.ts resolveFieldLlvmTypecalls.tsfield type resolutioncontrol-flow.tsswitch discriminantinterface-struct-generator.ts(4 sites)generator-context.tstype fallbackInfrastructure
ArrayKindenum +classifyArray+arrayKindToLlvmintype-system.tsisAnyArrayTsType()centralized guard checkisObjectArrayTsType()rewritten asclassifyArray(t) === ArrayKind_Object