Skip to content

fix(all): fix super call in multi-level generic class hierarchy using wrong mangled name#4414

Merged
MangelMaxime merged 1 commit into
mainfrom
repo-assist/fix-issue-3895-override-template-hash-20260317-115d695ce34451bd
May 27, 2026
Merged

fix(all): fix super call in multi-level generic class hierarchy using wrong mangled name#4414
MangelMaxime merged 1 commit into
mainfrom
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

@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
@MangelMaxime MangelMaxime force-pushed the repo-assist/fix-issue-3895-override-template-hash-20260317-115d695ce34451bd branch from 4524806 to 6145f51 Compare May 27, 2026 19:34
@MangelMaxime MangelMaxime changed the title [Repo Assist] [JS/TS] Fix super call in generic class hierarchy using wrong mangled name fix(all): fix super call in multi-level generic class hierarchy using wrong mangled name May 27, 2026
@github-actions
Copy link
Copy Markdown
Contributor Author

github-actions Bot commented May 27, 2026

Python Type Checking Results (Pyright)

Metric Value
Total errors 34
Files with errors 4
Excluded files 4
New errors ✅ No
Excluded files with errors (4 files)

These files have known type errors and are excluded from CI. Remove from pyrightconfig.ci.json as errors are fixed.

File Errors Status
temp/tests/Python/test_hash_set.py 18 Excluded
temp/tests/Python/test_applicative.py 12 Excluded
temp/tests/Python/test_nested_and_recursive_pattern.py 2 Excluded
temp/tests/Python/fable_modules/thoth_json_python/encode.py 2 Excluded

@MangelMaxime MangelMaxime force-pushed the repo-assist/fix-issue-3895-override-template-hash-20260317-115d695ce34451bd branch from 6145f51 to e427b51 Compare May 27, 2026 20:35
@MangelMaxime MangelMaxime merged commit db1d4d2 into main May 27, 2026
24 checks passed
@MangelMaxime MangelMaxime deleted the repo-assist/fix-issue-3895-override-template-hash-20260317-115d695ce34451bd branch May 27, 2026 20:47
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

1 participant