Problem
The native frontend lifts an arrow function and an ordinary function expression through the same closure path. The lifted EtsIR method does not retain that the arrow's this is captured from its creation site. When the function value is stored on another object and called there, this distinction is required for correct execution.
Minimal TypeScript example
class Box {
callback!: (value: number) => number;
constructor(public offset: number) {}
installOn(target: Box): void {
target.callback = (value: number) => this.offset + value;
}
call(value: number): number {
return this.callback(value);
}
}
export function lexicalThis(): number {
const source = new Box(11);
const target = new Box(100);
source.installOn(target);
return target.call(1);
}
lexicalThis() must return 12, because the arrow captures source as this; an ordinary function expression called through target.callback would use the call receiver instead.
Source evidence and observed consumer failure
The source links are pinned to JacoDB neo 873f8e99. The standalone snippet compiles with TypeScript and returns 12 under Node.js. It has not been run as a new JacoDB frontend regression; the reported 101 came from the related #418 test.
Acceptance criteria
- EtsIR distinguishes arrows from ordinary function expressions and preserves the lexical receiver of an arrow through JSON round trip.
- A focused frontend regression checks the distinction in the stored-function case above.
- A consumer can call the stored arrow and obtain
12 while ordinary functions continue to use their call receiver.
Problem
The native frontend lifts an arrow function and an ordinary function expression through the same closure path. The lifted EtsIR method does not retain that the arrow's
thisis captured from its creation site. When the function value is stored on another object and called there, this distinction is required for correct execution.Minimal TypeScript example
lexicalThis()must return12, because the arrow capturessourceasthis; an ordinary function expression called throughtarget.callbackwould use the call receiver instead.Source evidence and observed consumer failure
isStaticMethodfor arrows, but emits no function-kind marker or captured lexical receiver.thisfromThisRefin the lifted method.12, observed101. That test was moved out of [TS] Execute parameter defaults in declaration order (#372) #419 so its object-array input gap remains one issue.The source links are pinned to JacoDB
neo873f8e99. The standalone snippet compiles with TypeScript and returns12under Node.js. It has not been run as a new JacoDB frontend regression; the reported101came from the related #418 test.Acceptance criteria
12while ordinary functions continue to use their call receiver.