This commit is contained in:
Chris Wanstrath 2025-10-28 21:52:15 -07:00
parent 1aa1570135
commit b03610761b

View File

@ -475,8 +475,8 @@ export class Compiler {
// = can be a valid word, and also valid in words, so for now we cheat
// and check for arrays that look like `[ = ]` to interpret them as
// empty dicts
if (children.length === 1 && children[0].name === 'Word') {
const child = children[0]
if (children.length === 1 && children[0]!.name === 'Word') {
const child = children[0]!
if (input.slice(child.from, child.to) === '=') {
return [['MAKE_DICT', 0]]
}
@ -493,13 +493,13 @@ export class Compiler {
children.forEach((node) => {
const keyNode = node.firstChild
const valueNode = node.firstChild.nextSibling
const valueNode = node.firstChild!.nextSibling
// name= -> name
const key = input.slice(keyNode.from, keyNode.to).slice(0, -1)
const key = input.slice(keyNode!.from, keyNode!.to).slice(0, -1)
instructions.push(['PUSH', key])
instructions.push(...this.#compileNode(valueNode, input))
instructions.push(...this.#compileNode(valueNode!, input))
})
instructions.push(['MAKE_DICT', children.length])