@@ -1183,27 +1183,27 @@ auto TypeChecker::ExpectReturnOnAllPaths(
1183
1183
// TODO: Add checking to function definitions to ensure that
1184
1184
// all deduced type parameters will be deduced.
1185
1185
auto TypeChecker::DeclareFunctionDeclaration (Nonnull<FunctionDeclaration*> f,
1186
- const ImplScope& impl_scope )
1186
+ const ImplScope& enclosing_scope )
1187
1187
-> ErrorOr<Success> {
1188
1188
if (trace_) {
1189
1189
llvm::outs () << " ** declaring function " << f->name () << " \n " ;
1190
1190
}
1191
1191
// Bring the deduced parameters into scope
1192
1192
for (Nonnull<GenericBinding*> deduced : f->deduced_parameters ()) {
1193
- RETURN_IF_ERROR (TypeCheckExp (&deduced->type (), impl_scope ));
1193
+ RETURN_IF_ERROR (TypeCheckExp (&deduced->type (), enclosing_scope ));
1194
1194
SetConstantValue (deduced, arena_->New <VariableType>(deduced));
1195
1195
ASSIGN_OR_RETURN (Nonnull<const Value*> deduced_type,
1196
1196
InterpExp (&deduced->type (), arena_, trace_));
1197
1197
deduced->set_static_type (deduced_type);
1198
1198
}
1199
1199
// Type check the receiver pattern
1200
1200
if (f->is_method ()) {
1201
- RETURN_IF_ERROR (TypeCheckPattern (&f->me_pattern (), std::nullopt, impl_scope,
1202
- ValueCategory::Let));
1201
+ RETURN_IF_ERROR (TypeCheckPattern (&f->me_pattern (), std::nullopt,
1202
+ enclosing_scope, ValueCategory::Let));
1203
1203
}
1204
1204
// Type check the parameter pattern
1205
1205
RETURN_IF_ERROR (TypeCheckPattern (&f->param_pattern (), std::nullopt,
1206
- impl_scope , ValueCategory::Let));
1206
+ enclosing_scope , ValueCategory::Let));
1207
1207
1208
1208
// Create the impl_bindings
1209
1209
std::vector<Nonnull<const ImplBinding*>> impl_bindings;
@@ -1221,7 +1221,7 @@ auto TypeChecker::DeclareFunctionDeclaration(Nonnull<FunctionDeclaration*> f,
1221
1221
return_expression.has_value ()) {
1222
1222
// We ignore the return value because return type expressions can't bring
1223
1223
// new types into scope.
1224
- RETURN_IF_ERROR (TypeCheckExp (*return_expression, impl_scope ));
1224
+ RETURN_IF_ERROR (TypeCheckExp (*return_expression, enclosing_scope ));
1225
1225
// Should we be doing SetConstantValue instead? -Jeremy
1226
1226
// And shouldn't the type of this be Type?
1227
1227
ASSIGN_OR_RETURN (Nonnull<const Value*> ret_type,
@@ -1237,13 +1237,13 @@ auto TypeChecker::DeclareFunctionDeclaration(Nonnull<FunctionDeclaration*> f,
1237
1237
}
1238
1238
// Bring the impl bindings into scope
1239
1239
ImplScope function_scope;
1240
- function_scope.AddParent (&impl_scope );
1240
+ function_scope.AddParent (&enclosing_scope );
1241
1241
for (Nonnull<const ImplBinding*> impl_binding : impl_bindings) {
1242
1242
function_scope.Add (impl_binding->interface (),
1243
1243
*impl_binding->type_var ()->constant_value (),
1244
1244
impl_binding);
1245
1245
}
1246
- RETURN_IF_ERROR (TypeCheckStmt (*f->body (), impl_scope ));
1246
+ RETURN_IF_ERROR (TypeCheckStmt (*f->body (), enclosing_scope ));
1247
1247
if (!f->return_term ().is_omitted ()) {
1248
1248
RETURN_IF_ERROR (ExpectReturnOnAllPaths (f->body (), f->source_loc ()));
1249
1249
}
@@ -1417,11 +1417,11 @@ auto TypeChecker::TypeCheckImplDeclaration(Nonnull<ImplDeclaration*> impl_decl,
1417
1417
}
1418
1418
1419
1419
auto TypeChecker::DeclareChoiceDeclaration (Nonnull<ChoiceDeclaration*> choice,
1420
- const ImplScope& impl_scope )
1420
+ const ImplScope& enclosing_scope )
1421
1421
-> ErrorOr<Success> {
1422
1422
std::vector<NamedValue> alternatives;
1423
1423
for (Nonnull<AlternativeSignature*> alternative : choice->alternatives ()) {
1424
- RETURN_IF_ERROR (TypeCheckExp (&alternative->signature (), impl_scope ));
1424
+ RETURN_IF_ERROR (TypeCheckExp (&alternative->signature (), enclosing_scope ));
1425
1425
ASSIGN_OR_RETURN (auto signature,
1426
1426
InterpExp (&alternative->signature (), arena_, trace_));
1427
1427
alternatives.push_back ({.name = alternative->name (), .value = signature});
@@ -1432,8 +1432,8 @@ auto TypeChecker::DeclareChoiceDeclaration(Nonnull<ChoiceDeclaration*> choice,
1432
1432
return Success ();
1433
1433
}
1434
1434
1435
- auto TypeChecker::TypeCheckChoiceDeclaration (Nonnull<ChoiceDeclaration*> choice,
1436
- const ImplScope& impl_scope)
1435
+ auto TypeChecker::TypeCheckChoiceDeclaration (
1436
+ Nonnull<ChoiceDeclaration*> /* choice */ , const ImplScope& /* impl_scope*/ )
1437
1437
-> ErrorOr<Success> {
1438
1438
// Nothing to do here, but perhaps that will change in the future?
1439
1439
return Success ();
@@ -1504,34 +1504,35 @@ auto TypeChecker::TypeCheckDeclaration(Nonnull<Declaration*> d,
1504
1504
}
1505
1505
1506
1506
auto TypeChecker::DeclareDeclaration (Nonnull<Declaration*> d,
1507
- ImplScope& impl_scope )
1507
+ ImplScope& enclosing_scope )
1508
1508
-> ErrorOr<Success> {
1509
1509
switch (d->kind ()) {
1510
1510
case DeclarationKind::InterfaceDeclaration: {
1511
1511
auto & iface_decl = cast<InterfaceDeclaration>(*d);
1512
- RETURN_IF_ERROR (DeclareInterfaceDeclaration (&iface_decl, impl_scope));
1512
+ RETURN_IF_ERROR (
1513
+ DeclareInterfaceDeclaration (&iface_decl, enclosing_scope));
1513
1514
break ;
1514
1515
}
1515
1516
case DeclarationKind::ImplDeclaration: {
1516
1517
auto & impl_decl = cast<ImplDeclaration>(*d);
1517
- RETURN_IF_ERROR (DeclareImplDeclaration (&impl_decl, impl_scope ));
1518
+ RETURN_IF_ERROR (DeclareImplDeclaration (&impl_decl, enclosing_scope ));
1518
1519
break ;
1519
1520
}
1520
1521
case DeclarationKind::FunctionDeclaration: {
1521
1522
auto & func_def = cast<FunctionDeclaration>(*d);
1522
- RETURN_IF_ERROR (DeclareFunctionDeclaration (&func_def, impl_scope ));
1523
+ RETURN_IF_ERROR (DeclareFunctionDeclaration (&func_def, enclosing_scope ));
1523
1524
break ;
1524
1525
}
1525
1526
1526
1527
case DeclarationKind::ClassDeclaration: {
1527
1528
auto & class_decl = cast<ClassDeclaration>(*d);
1528
- RETURN_IF_ERROR (DeclareClassDeclaration (&class_decl, impl_scope ));
1529
+ RETURN_IF_ERROR (DeclareClassDeclaration (&class_decl, enclosing_scope ));
1529
1530
break ;
1530
1531
}
1531
1532
1532
1533
case DeclarationKind::ChoiceDeclaration: {
1533
1534
auto & choice = cast<ChoiceDeclaration>(*d);
1534
- RETURN_IF_ERROR (DeclareChoiceDeclaration (&choice, impl_scope ));
1535
+ RETURN_IF_ERROR (DeclareChoiceDeclaration (&choice, enclosing_scope ));
1535
1536
break ;
1536
1537
}
1537
1538
@@ -1545,8 +1546,8 @@ auto TypeChecker::DeclareDeclaration(Nonnull<Declaration*> d,
1545
1546
}
1546
1547
Expression& type =
1547
1548
cast<ExpressionPattern>(var.binding ().type ()).expression ();
1548
- RETURN_IF_ERROR (TypeCheckPattern (&var.binding (), std::nullopt, impl_scope,
1549
- var.value_category ()));
1549
+ RETURN_IF_ERROR (TypeCheckPattern (&var.binding (), std::nullopt,
1550
+ enclosing_scope, var.value_category ()));
1550
1551
ASSIGN_OR_RETURN (Nonnull<const Value*> declared_type,
1551
1552
InterpExp (&type, arena_, trace_));
1552
1553
var.set_static_type (declared_type);
0 commit comments