-
Notifications
You must be signed in to change notification settings - Fork 88
Add majorDiameter and minorDiameter to ellipse fns #8057
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
base: main
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for GitHub.
|
CodSpeed Instrumentation Performance ReportMerging #8057 will not alter performanceComparing Summary
|
let major_radius = match (major_radius, major_diameter) { | ||
(Some(_), Some(_)) | (None, None) => { | ||
return Err(KclError::new_type(KclErrorDetails::new( | ||
"Provide either `majorDiameter` or `majorRadius`, not both.".to_string(), | ||
vec![args.source_range], | ||
))); | ||
} | ||
(Some(major_radius), _) => Some(major_radius), | ||
(_, Some(major_diameter)) => Some(TyF64 { | ||
n: 0.5 * major_diameter.n, | ||
ty: major_diameter.ty, | ||
}), | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Validation logic issue with optional parameters
There's a validation error in the major_radius
matching logic. When both majorRadius
and majorDiameter
are None
, the code returns an error:
(Some(_), Some(_)) | (None, None) => {
return Err(KclError::new_type(KclErrorDetails::new(
"Provide either `majorDiameter` or `majorRadius`, not both.".to_string(),
vec![args.source_range],
)));
}
However, according to the function signature, majorRadius
is optional, and users can provide majorAxis
instead. This validation breaks backward compatibility for code that uses majorAxis
without specifying either radius parameter.
The validation should only reject cases where both diameter and radius are provided simultaneously, not when both are absent.
let major_radius = match (major_radius, major_diameter) { | |
(Some(_), Some(_)) | (None, None) => { | |
return Err(KclError::new_type(KclErrorDetails::new( | |
"Provide either `majorDiameter` or `majorRadius`, not both.".to_string(), | |
vec![args.source_range], | |
))); | |
} | |
(Some(major_radius), _) => Some(major_radius), | |
(_, Some(major_diameter)) => Some(TyF64 { | |
n: 0.5 * major_diameter.n, | |
ty: major_diameter.ty, | |
}), | |
}; | |
let major_radius = match (major_radius, major_diameter) { | |
(Some(_), Some(_)) => { | |
return Err(KclError::new_type(KclErrorDetails::new( | |
"Provide either `majorDiameter` or `majorRadius`, not both.".to_string(), | |
vec![args.source_range], | |
))); | |
} | |
(Some(major_radius), _) => Some(major_radius), | |
(_, Some(major_diameter)) => Some(TyF64 { | |
n: 0.5 * major_diameter.n, | |
ty: major_diameter.ty, | |
}), | |
(None, None) => None, | |
}; | |
Spotted by Diamond
Is this helpful? React 👍 or 👎 to let us know.
To align the ellipse fns with circle, you can now specify the major/minor diameter of the ellipse instead of the radius