Skip to content

Commit

Permalink
fixes #1689 (#1690)
Browse files Browse the repository at this point in the history
  • Loading branch information
martin-henz authored Apr 23, 2024
1 parent 9819f2c commit a5b6f47
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "js-slang",
"version": "1.0.72",
"version": "1.0.73",
"license": "Apache-2.0",
"description": "Javascript-based implementations of Source, written in Typescript",
"keywords": [
Expand Down
11 changes: 5 additions & 6 deletions src/utils/ast/astToString.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,33 +44,32 @@ const sourceGen = Object.assign({}, astring.GENERATOR, {
StatementSequence: function (node: any, state: any) {
const indent = state.indent.repeat(state.indentLevel)
const { lineEnd, writeComments } = state
const statementIndent = indent + state.indent
const statements = node.body
if (statements != null && statements.length > 0) {
state.write(lineEnd)
if (writeComments && node.comments != null) {
formatComments(state, node.comments, statementIndent, lineEnd)
formatComments(state, node.comments, indent, lineEnd)
}
const { length } = statements
for (let i = 0; i < length; i++) {
const statement = statements[i]
if (writeComments && statement.comments != null) {
formatComments(state, statement.comments, statementIndent, lineEnd)
formatComments(state, statement.comments, indent, lineEnd)
}
state.write(statementIndent)
state.write(indent)
this[statement.type](statement, state)
state.write(lineEnd)
}
state.write(indent)
} else {
if (writeComments && node.comments != null) {
state.write(lineEnd)
formatComments(state, node.comments, statementIndent, lineEnd)
formatComments(state, node.comments, indent, lineEnd)
state.write(indent)
}
}
if (writeComments && node.trailingComments != null) {
formatComments(state, node.trailingComments, statementIndent, lineEnd)
formatComments(state, node.trailingComments, indent, lineEnd)
}
}
})
Expand Down

0 comments on commit a5b6f47

Please sign in to comment.