@@ -7497,6 +7497,14 @@ export class Compiler extends DiagnosticEmitter {
74977497 // Analyze captured variables before compiling
74987498 let captures = this . analyzeCapturedVariables ( declaration , flow ) ;
74997499 if ( captures . size > 0 ) {
7500+ // Check if closures feature is enabled
7501+ if ( ! this . options . hasFeature ( Feature . Closures ) ) {
7502+ this . error (
7503+ DiagnosticCode . Feature_0_is_not_enabled ,
7504+ expression . range , "closures"
7505+ ) ;
7506+ return module . unreachable ( ) ;
7507+ }
75007508 instance . capturedLocals = captures ;
75017509 instance . outerFunction = sourceFunction ;
75027510 this . ensureClosureEnvironment ( sourceFunction , captures , flow ) ;
@@ -7515,6 +7523,14 @@ export class Compiler extends DiagnosticEmitter {
75157523 // Analyze captured variables before compiling
75167524 let captures = this . analyzeCapturedVariables ( declaration , flow ) ;
75177525 if ( captures . size > 0 ) {
7526+ // Check if closures feature is enabled
7527+ if ( ! this . options . hasFeature ( Feature . Closures ) ) {
7528+ this . error (
7529+ DiagnosticCode . Feature_0_is_not_enabled ,
7530+ expression . range , "closures"
7531+ ) ;
7532+ return module . unreachable ( ) ;
7533+ }
75187534 instance . capturedLocals = captures ;
75197535 instance . outerFunction = sourceFunction ;
75207536 this . ensureClosureEnvironment ( sourceFunction , captures , flow ) ;
@@ -7990,6 +8006,14 @@ export class Compiler extends DiagnosticEmitter {
79908006 let declaration = funcExpr . declaration ;
79918007 let capturedNames = this . analyzeCapturedVariablesWithDeclared ( declaration , flow , instance , declaredVars ) ;
79928008 if ( capturedNames . size > 0 ) {
8009+ // Check if closures feature is enabled
8010+ if ( ! this . options . hasFeature ( Feature . Closures ) ) {
8011+ this . error (
8012+ DiagnosticCode . Feature_0_is_not_enabled ,
8013+ funcExpr . range , "closures"
8014+ ) ;
8015+ break ;
8016+ }
79938017 // Store captured names for later use when compiling variable declarations
79948018 let existingNames = instance . preCapturedNames ;
79958019 if ( ! existingNames ) {
0 commit comments