Skip to content

[Repo Assist] [JS/TS] Fix super call in generic class hierarchy using wrong mangled name#4414

Open
github-actions[bot] wants to merge 1 commit intomainfrom
repo-assist/fix-issue-3895-override-template-hash-20260317-115d695ce34451bd
Open

[Repo Assist] [JS/TS] Fix super call in generic class hierarchy using wrong mangled name#4414
github-actions[bot] wants to merge 1 commit intomainfrom
repo-assist/fix-issue-3895-override-template-hash-20260317-115d695ce34451bd

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

🤖 This PR was created by Repo Assist, an automated AI assistant.

Summary

Fixes #3895super.Method() calls in multi-level generic class hierarchies generate the wrong mangled name, causing a runtime error like super.OverrideIssue.AspectBase\1.Attach1505 is not a function`.

Root Cause

When callAttachedMember computes the mangled name for a super call, it calls getOverloadSuffixFrom(baseEntity, overrideMember). The hash is computed by mapping the base entity's generic parameter names (e.g. 'C) to positional indices — but the override member's parameter types use the intermediate class's generic parameter names (e.g. 'Container). The dict lookup fails, the type falls back to an empty constraint string, and produces a different hash than the one used at method definition time.

Example:

  • AspectBase<'C> defines Attach('C) — hash computed as genParams={"C"→"0"}, type "C"→"0" → hash 2B595
  • ProjectSelection.Attach calls base.Attach(owner) — Fable finds AspectBase as the base entity, but uses SelectionAspect<'Container>.Attach as the member. genParams={"C"→"0"} but type is "Container" → not in dict → hash 1505

Fix

After finding the base entity with tryFindBaseEntity, also call tryFindAbstractMember to retrieve the dispatch slot from that entity and pass it to callAttachedMember. This ensures both ent and memb share the same generic parameter namespace, producing a consistent hash.

Changed file: src/Fable.Transforms/FSharp2Fable.Util.fs — targeted change in the super-call entity resolution block (~10 lines).

Test Plan

  • Added a test in tests/Js/Main/TypeTests.fs that creates a 3-level generic class hierarchy and calls Attach("hello"), verifying the base method was invoked (would throw at runtime before this fix)
  • The fix is limited to the super-call path; normal virtual dispatch and interface calls are unaffected

🤖 Generated with Repo Assist

Generated by Repo Assist ·

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@346204513ecfa08b81566450d7d599556807389f

…gled name (fix #3895)

When calling `base.Method()` in a class that inherits through a chain of generic
classes, the overload hash suffix was computed incorrectly. For example, if
`ProjectSelection` inherits `SelectionAspect<'Container>` which inherits
`AspectBase<'C>`, calling `base.Attach(owner)` from `ProjectSelection.Attach`
would generate `super["...AspectBase.Attach1505"]` but the method was defined as
`"...AspectBase.Attach2B595"`, causing a runtime error.

Root cause: `callAttachedMember` was called with the correct base entity
(`AspectBase<'C>`) but the override member from the intermediate class
(`SelectionAspect<'Container>.Attach`). `getOverloadSuffixFrom` uses the entity's
generic param names (`['C']`) as normalization keys, but the member's parameter
types use the intermediate class's names (`'Container`), causing the lookup to
fail and producing a different hash.

Fix: after finding the base entity with `tryFindBaseEntity`, also find the
corresponding dispatch slot member in that entity so the hash is computed with
matching entity and member generic parameter names.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions github-actions bot added automation Automated changes repo-assist Created by Repo Assist labels Mar 17, 2026
@MangelMaxime MangelMaxime marked this pull request as ready for review March 18, 2026 22:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automation Automated changes repo-assist Created by Repo Assist

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Override produces broken Javascript with template

0 participants