Skip to content

Commit

Permalink
Handle errors during proto transformation in the type-checker
Browse files Browse the repository at this point in the history
  • Loading branch information
TristonianJones committed Aug 9, 2023
1 parent cfc9b0c commit fff4ebe
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions checker/checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,13 @@ type checker struct {
}

// Check performs type checking, giving a typed AST.
// The input is a ParsedExpr proto and an env which encapsulates
// type binding of variables, declarations of built-in functions,
// descriptions of protocol buffers, and a registry for errors.
// Returns a CheckedExpr proto, which might not be usable if
// there are errors in the error registry.
//
// The input is a ParsedExpr proto and an env which encapsulates type binding of variables,
// declarations of built-in functions, descriptions of protocol buffers, and a registry for
// errors.
//
// Returns a type-checked AST, which might not be usable if there are errors in the error
// registry.
func Check(parsedExpr *exprpb.ParsedExpr, source common.Source, env *Env) (*ast.AST, *common.Errors) {
errs := common.NewErrors(source)
c := checker{
Expand All @@ -66,11 +68,11 @@ func Check(parsedExpr *exprpb.ParsedExpr, source common.Source, env *Env) (*ast.
}
e, err := ast.ProtoToExpr(parsedExpr.GetExpr())
if err != nil {

errs.ReportError(common.NoLocation, err.Error())
}
info, err := ast.ProtoToSourceInfo(parsedExpr.GetSourceInfo())
if err != nil {

errs.ReportError(common.NoLocation, err.Error())
}
return ast.NewCheckedAST(ast.NewAST(e, info), m, c.references), errs
}
Expand Down

0 comments on commit fff4ebe

Please sign in to comment.