Skip to content

Commit

Permalink
Fix let block without variables
Browse files Browse the repository at this point in the history
  • Loading branch information
fredrikekre committed Jul 8, 2024
1 parent 668527d commit 6cb6057
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/runestone.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1314,7 +1314,9 @@ function indent_let(ctx::Context, node::Node)
vars_idx = 2
vars_node = kids[vars_idx]
@assert !is_leaf(vars_node) && kind(vars_node) === K"block"
@assert kind(last_leaf(vars_node)) !== "NewlineWs"
if span(vars_node) > 0 && length(verified_kids(vars_node)) > 0
@assert kind(last_leaf(vars_node)) !== "NewlineWs"
end
# Third node is the NewlineWs before the block
ln_idx = 3
ln_node = kids[ln_idx]
Expand Down
2 changes: 2 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,8 @@ end
# let-end
@test format_string("let a = 1\n$(sp)x\n$(sp)end") ==
"let a = 1\n x\nend"
@test format_string("let\n$(sp)x\n$(sp)end") ==
"let\n x\nend"
# begin-end
@test format_string("begin\n$(sp)x\n$(sp)end") ==
"begin\n x\nend"
Expand Down

0 comments on commit 6cb6057

Please sign in to comment.