Skip to content

Commit

Permalink
Update on "[compiler] Implement support for hoisted and recursive fun…
Browse files Browse the repository at this point in the history
…ctions"

Summary:
Introduces a new binding kind for functions that allows them to be hoisted. Also has the result of causing all nested function declarations to be outputted as function declarations, not as let bindings.

[ghstack-poisoned]
  • Loading branch information
mvitousek committed Sep 9, 2024
2 parents 6508bf7 + fcd75a1 commit b308f2f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 185 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -981,36 +981,12 @@ function codegenTerminal(
suggestions: null,
});
case InstructionKind.Catch:
CompilerError.invariant(false, {
reason: 'Unexpected catch variable as for..in collection',
description: null,
loc: iterableItem.loc,
suggestions: null,
});
case InstructionKind.HoistedConst:
CompilerError.invariant(false, {
reason: 'Unexpected HoistedConst variable in for..in collection',
description: null,
loc: iterableItem.loc,
suggestions: null,
});
case InstructionKind.HoistedLet:
CompilerError.invariant(false, {
reason: 'Unexpected HoistedLet variable in for..in collection',
description: null,
loc: iterableItem.loc,
suggestions: null,
});
case InstructionKind.HoistedFunction:
CompilerError.invariant(false, {
reason: 'Unexpected HoistedFunction variable in for..in collection',
description: null,
loc: iterableItem.loc,
suggestions: null,
});
case InstructionKind.Function:
CompilerError.invariant(false, {
reason: 'Unexpected Function variable in for..in collection',
reason: `Unexpected ${iterableItem.value.lvalue.kind} variable in for..in collection`,
description: null,
loc: iterableItem.loc,
suggestions: null,
Expand Down Expand Up @@ -1089,44 +1065,13 @@ function codegenTerminal(
varDeclKind = 'let' as const;
break;
case InstructionKind.Reassign:
CompilerError.invariant(false, {
reason:
'Destructure should never be Reassign as it would be an Object/ArrayPattern',
description: null,
loc: iterableItem.loc,
suggestions: null,
});
case InstructionKind.Catch:
CompilerError.invariant(false, {
reason: 'Unexpected catch variable as for..of collection',
description: null,
loc: iterableItem.loc,
suggestions: null,
});
case InstructionKind.HoistedConst:
CompilerError.invariant(false, {
reason: 'Unexpected HoistedConst variable in for..of collection',
description: null,
loc: iterableItem.loc,
suggestions: null,
});
case InstructionKind.HoistedLet:
CompilerError.invariant(false, {
reason: 'Unexpected HoistedLet variable in for..of collection',
description: null,
loc: iterableItem.loc,
suggestions: null,
});
case InstructionKind.HoistedFunction:
CompilerError.invariant(false, {
reason: 'Unexpected HoistedFunction variable in for..of collection',
description: null,
loc: iterableItem.loc,
suggestions: null,
});
case InstructionKind.Function:
CompilerError.invariant(false, {
reason: 'Unexpected Function variable in for..of collection',
reason: `Unexpected ${iterableItem.value.lvalue.kind} variable in for..of collection`,
description: null,
loc: iterableItem.loc,
suggestions: null,
Expand Down Expand Up @@ -1360,28 +1305,11 @@ function codegenInstructionNullable(
case InstructionKind.Catch: {
return t.emptyStatement();
}
case InstructionKind.HoistedLet: {
CompilerError.invariant(false, {
reason:
'Expected HoistedLet to have been pruned in PruneHoistedContexts',
description: null,
loc: instr.loc,
suggestions: null,
});
}
case InstructionKind.HoistedConst: {
CompilerError.invariant(false, {
reason:
'Expected HoistedConsts to have been pruned in PruneHoistedContexts',
description: null,
loc: instr.loc,
suggestions: null,
});
}
case InstructionKind.HoistedLet:
case InstructionKind.HoistedConst:
case InstructionKind.HoistedFunction: {
CompilerError.invariant(false, {
reason:
'Expected HoistedFunction to have been pruned in PruneHoistedContexts',
reason: `Expected ${kind} to have been pruned in PruneHoistedContexts`,
description: null,
loc: instr.loc,
suggestions: null,
Expand Down

This file was deleted.

This file was deleted.

0 comments on commit b308f2f

Please sign in to comment.