Skip to content

Commit

Permalink
Suppress arity errors in elaborator
Browse files Browse the repository at this point in the history
  • Loading branch information
FlandiaYingman committed Jan 3, 2025
1 parent a9ba3c9 commit 7052f6d
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions hkmc2/shared/src/main/scala/hkmc2/semantics/Elaborator.scala
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,9 @@ extends Importer:
case (S(defn: TermDefinition), inner, argLists) =>
log(s"Elab module method definition w/ type information ${defn}.")
val emptyTreeApp = new Tree.App(Tree.Empty(), Tree.Empty())
// Zips a module method application term along with its parameter lists.
// Zips a module method application term along with its parameter lists,
// inserting any missing contextual argument lists.
//
// Example:
// fun f(...)(using ...)()(using...) // function definition
// f()() // function application
Expand All @@ -522,12 +524,13 @@ extends Importer:
log(s"Inserted missing contextual argument list: ${args}")
Term.App(zip(t, pRest), args)(emptyTreeApp, FlowSymbol("‹app-res›"))
case (t @ Term.App(lhs, rhs), params :: pRest) =>
// TODO: Perform argument checks here.
Term.App(zip(lhs, pRest), rhs)(t.tree, t.resSym)
case (_, params :: pRest) =>
// TODO: Fail silently and perform the checks in the implicit resolver.
raise(ErrorReport(msg"Argument arity do not match the method signature." -> t.toLoc :: Nil))
Term.Error
case (t, params :: pRest) =>
// LHS is not a app but it still expects more param lists - a partial application.
// TODO: Don't fail here. Perform if it is legal in the implicit resolver.
// raise(ErrorReport(msg"Argument arity do not match the method signature." -> t.toLoc :: Nil))
// Term.Error
t
case (_, Nil) => t
val newTerm = zip(t, defn.params.reverse)
log(s"Zipped argument lists: ${newTerm}")
Expand Down

0 comments on commit 7052f6d

Please sign in to comment.