Fix: Center rectangle now works again, works with new LiteralValue structure (#5172)
* fix: new Literal data structure update * fix: updated the LiteralValue dereferencing and added some type narrowing helpers * fix: updating formatting * A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores) * fix: implementing a safer dereference method until we update createLiteraly() * A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores) * why is this fallback here * fix: updating the type narrowing function * fix: restore this... see if snapshots trigger again * A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores) * bump * bump * Add number with units formatting as KCL (#5195) * Add number with units formatting as KCL * Change type assertion helper to check what we need * Fix rectangle unit test * fix: adding a wait for execution to prevent clicking before lines are rendered --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Jonathan Tran <jonnytran@gmail.com>
This commit is contained in:
@ -8,13 +8,19 @@ import {
|
||||
createTagDeclarator,
|
||||
createUnaryExpression,
|
||||
} from 'lang/modifyAst'
|
||||
import { ArrayExpression, CallExpression, PipeExpression } from 'lang/wasm'
|
||||
import {
|
||||
ArrayExpression,
|
||||
CallExpression,
|
||||
PipeExpression,
|
||||
recast,
|
||||
} from 'lang/wasm'
|
||||
import { roundOff } from 'lib/utils'
|
||||
import {
|
||||
isCallExpression,
|
||||
isArrayExpression,
|
||||
isLiteral,
|
||||
isBinaryExpression,
|
||||
isLiteralValueNumber,
|
||||
} from 'lang/util'
|
||||
|
||||
/**
|
||||
@ -140,10 +146,12 @@ export function updateCenterRectangleSketch(
|
||||
if (isArrayExpression(arrayExpression)) {
|
||||
const literal = arrayExpression.elements[0]
|
||||
if (isLiteral(literal)) {
|
||||
callExpression.arguments[0] = createArrayExpression([
|
||||
createLiteral(literal.value),
|
||||
createLiteral(Math.abs(twoX)),
|
||||
])
|
||||
if (isLiteralValueNumber(literal.value)) {
|
||||
callExpression.arguments[0] = createArrayExpression([
|
||||
createLiteral(literal.value),
|
||||
createLiteral(Math.abs(twoX)),
|
||||
])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user