Hacktoberfest 2026: as issues que os mantenedores marcaram para outubro, abertas e boas para iniciantes. Ver issues do Hacktoberfest

[TS] Bind lexical this when calling stored arrow functions

Aberta
#440 0 comentários 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 1 dia

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
4/5
Tempo estimado
3-5 dias
Facilidade para iniciantes
48/100
Tipo de issue
Bug
Clareza
Razoavelmente clara
Status de atividade
Ativa
Stack de tecnologia
kotlin, typescript
Domínio
compilers, testing-qa

Direção de pesquisa

Start with TsExprResolver.kt at the function-reference creation and indirect call resolution locations cited in the issue, and review the EtsIR dependency in UnitTestBot/jacodb#391. Replay lexicalThis through USVM and compare it with the TypeScript/Node.js result. Done means stored arrows return 12, ordinary stored functions retain dynamic receivers, and a focused test records both results.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

enhancement

Problem

A stored arrow function is called with the receiver of the property access instead of the this captured where the arrow was created. This is independent of the object-array symbolic-input problem that remains in #419.

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() returns 12 in TypeScript/Node.js. The related StoredFunctionCall test reported in #419 on the #418 head returned 101 in USVM, using the target receiver instead of the source receiver. This standalone snippet has not yet been replayed through USVM.

Dependency and source evidence

  • UnitTestBot/jacodb#391 tracks preserving the arrow/function distinction and lexical receiver in EtsIR. This issue owns the USVM call binding after that representation is available.
  • Function-reference creation constructs the reference from the lifted method and closure environment.
  • Indirect call resolution uses callee.thisInstance for the call.

The source links are pinned to USVM main 53dce8f3. The related failure was observed on the #418 head; it is not claimed as a fresh main-branch replay.

Acceptance criteria

  • A stored arrow retains its lexical this when assigned to and called through another object; the example returns 12.
  • An ordinary stored function expression still uses its dynamic call receiver.
  • A focused test checks the USVM result and confirms a concrete TypeScript/Node.js replay.
Linguagem predominante
Kotlin
Estrelas
33
Forks
27
Merge médio
2d 20h
PRs com merge (30d)
10

Preparar o ambiente

Este projeto não oferece contêiner de desenvolvimento, Dockerfile nem guia de contribuição, então a configuração fica por sua conta: comece pelo README e veja nosso guia da primeira contribuição para os passos gerais.

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de UnitTestBot/usvm

Todas as issues de UnitTestBot/usvm

Issues semelhantes

Mais issues de Kotlin

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.