Skip to content

Fix to not duplicate arg labels on constrained sketches #6337

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 17, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/lang/modifyAst.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,8 @@ export function addSketchTo(
Set the keyword argument to the given value.
Returns true if it overwrote an existing argument.
Returns false if no argument with the label existed before.
Returns 'no-mutate' if the label was found, but the value is constrained and not
mutated.
Also do some checks to see if it's actually trying to set a constraint on
a sketch line that's already fully constrained, and if so, duplicates the arg.
WILL BE FIXED SOON.
Expand All @@ -235,7 +237,7 @@ export function mutateKwArg(
label: string,
node: CallExpressionKw,
val: Expr
): boolean {
): boolean | 'no-mutate' {
for (let i = 0; i < node.arguments.length; i++) {
const arg = node.arguments[i]
if (arg.label.name === label) {
Expand All @@ -254,6 +256,8 @@ export function mutateKwArg(
})
return true
}
// The label was found, but the value is not a literal or static.
return 'no-mutate'
}
}
node.arguments.push(createLabeledArg(label, val))
Expand Down
Loading