Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
bcpeinhardt committed Dec 14, 2024
1 parent 955fab3 commit bfe471b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 20 deletions.
12 changes: 2 additions & 10 deletions priv/static/squared_away.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7717,17 +7717,9 @@ function typecheck(env, expr) {
);
if (defs === 0) {
return new Ok(new LabelDef2(new TNil(), txt));
} else if (defs === 1) {
return new Ok(new LabelDef2(new TNil(), txt));
} else if (defs > 1) {
return new Error(
new TypeError2(new TypeError("Duplicate Label"))
);
} else {
return new Error(
new TypeError2(
new TypeError("This is an internal compiler error.")
)
new TypeError2(new TypeError("Duplicate Label"))
);
}
} else if (expr instanceof Label) {
Expand Down Expand Up @@ -9361,7 +9353,7 @@ function view(model) {
let _pipe$32 = model.compiler_state.deps_graph;
let _pipe$42 = filter(
_pipe$32,
(k, v) => {
(_2, v) => {
return contains(v, active_cell);
}
);
Expand Down
6 changes: 4 additions & 2 deletions src/squared_away/compiler.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
//// an initial set of grids for all the cells, and try to only
//// compile and update what we need based on the dependency graph.

import squared_away/squared_away_lang/parser/parse_error
import gleam/dict
import gleam/list
import gleam/option
import gleam/bool
import gleam/result
import gleam/set
import squared_away/squared_away_lang/error
Expand Down Expand Up @@ -107,6 +109,7 @@ pub fn edit_cell(state: State, key: grid.GridKey, src: String) -> State {
use parsed <- result.try(
parser.parse(scanned) |> result.map_error(error.ParseError),
)

use typechecked <- result.try(typechecker.typecheck(
state |> get_parsed,
parsed,
Expand All @@ -132,6 +135,7 @@ pub fn edit_cell(state: State, key: grid.GridKey, src: String) -> State {
state |> get_typechecked,
typechecked,
))

Ok(#(
CompileSteps(scanned:, parsed:, typechecked:, interpreted:),
deps_graph,
Expand All @@ -147,8 +151,6 @@ pub fn edit_cell(state: State, key: grid.GridKey, src: String) -> State {
)
}
Ok(#(cell, deps_graph)) -> {
// If the process succeeded, we need to update the cells value AND the dependency
// graph with the cells new dependencies.
State(
cells: grid.insert(state.cells, key, Cell(src:, outcome: Ok(cell))),
deps_graph:,
Expand Down
10 changes: 2 additions & 8 deletions src/squared_away/squared_away_lang/typechecker.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -177,15 +177,9 @@ pub fn typecheck(
})

case defs {
0 | 1 -> Ok(typed_expr.LabelDef(typ.TNil, txt))
_ if defs > 1 ->
Error(error.TypeError(type_error.TypeError("Duplicate Label")))
0 -> Ok(typed_expr.LabelDef(typ.TNil, txt))
_ ->
Error(
error.TypeError(type_error.TypeError(
"This is an internal compiler error.",
)),
)
Error(error.TypeError(type_error.TypeError("Duplicate Label")))
}
}
expr.Label(txt) -> {
Expand Down

0 comments on commit bfe471b

Please sign in to comment.