Skip to content

Commit

Permalink
remove else branches
Browse files Browse the repository at this point in the history
  • Loading branch information
Kris Brown committed Oct 26, 2023
1 parent 0348cb8 commit 49a4ab1
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 8 deletions.
8 changes: 0 additions & 8 deletions src/syntax/gats/algorithms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ function sortcheck(ctx::Context, t::AlgTerm)::AlgSort
AlgSort(judgment.type)
elseif judgment isa AlgStruct
AlgSort(headof(bodyof(t)), methodof(bodyof(t)))
else
error("Unexpected app $t")
end
elseif isvariable(t)
type = ctx[t.body] |> getvalue
Expand All @@ -27,8 +25,6 @@ function sortcheck(ctx::Context, t::AlgTerm)::AlgSort
AlgSort(ctx, t)
elseif isconstant(t)
AlgSort(t.body.type)
else
error("Make this branch explicit if it's ever used $t")
end
end

Expand Down Expand Up @@ -202,14 +198,10 @@ function substitute_funs(ctx::Context, t::AlgTerm)
elseif m isa AlgFunction
subst = Dict(zip(idents(m.localcontext; lid=m.args), argsof(b)))
substitute_term(m.value, subst)
else
error("Bad app $m")
end
elseif isvariable(t) || isconstant(t)
t
elseif isdot(t)
AlgTerm(AlgDot(headof(b), substitute_funs(ctx, bodyof(b)), b.sort))
else
error("Bad term $t")
end
end
2 changes: 2 additions & 0 deletions test/syntax/GATs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ three = AlgTerm(plus, plusmethod, [one, two])

@test fromexpr(GAT(:Empty), two.body, AlgTerm) == two

@test GATs.substitute_funs(scope, one) == one

@test basicprinted(two) == "AlgTerm(2::number)"

@test_throws Exception AlgSort(scope, three)
Expand Down

0 comments on commit 49a4ab1

Please sign in to comment.