web-mobile build rewrites super accessor setter and causes infinite recursion
Cocos Creator version
3.8.8
System information
Windows, web-mobile (H5) build
Issue description
A subclass accessor setter that assigns through a parent accessor with super.value = value is compiled incorrectly by the Creator 3.8.8 web-mobile build pipeline. The generated JavaScript changes the assignment target to the current instance (this.value = value), which re-enters the child setter forever and causes a stack overflow.
The repro does not depend on Cocos runtime classes:
class ProbeParent {
private _value = 0;
get value(): number {
return this._value;
}
set value(value: number) {
this._value = value;
}
}
class ProbeChild extends ProbeParent {
override get value(): number {
return super.value;
}
override set value(value: number) {
super.value = value;
}
}
const probe = new ProbeChild();
probe.value = 7;Steps to reproduce
- Create a Creator 3.8.8 project.
- Add the minimal TypeScript code above to a script included in the start scene.
- Build the project for web-mobile.
- Inspect the generated main bundle under assets/main/index.js.
- Run the H5 build.
Actual behavior
The generated bundle contains the child setter in this form:
set:function(e){this.value=e}Executing the generated setter produces:
RangeError: Maximum call stack size exceededThe same problem reproduces with an application class such as AudioMusic extends AudioSource when its setter contains super.volume = ....
Expected behavior
The generated code should preserve the ECMAScript semantics of a super property assignment: invoke the parent setter with the current child instance as the receiver. It must not rewrite the assignment as this.value = value.
Additional information
- The Creator 3.8.8 web-mobile build itself reports success with exit code 36.
- A standalone minimal repro was built and inspected in a separate Creator project.
- A related older discussion exists here: https://forum.cocosengine.org/t/cocos-creator-set-super-is-cause-of-rangeerror-maximum-call-stack-size-exceeded/54552
A workaround is to avoid assigning through a super accessor and expose a method or call the parent setter descriptor explicitly, but the original TypeScript syntax is valid and should survive the H5 transform.
Source: cocos/cocos-engine