-
Notifications
You must be signed in to change notification settings - Fork 8
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
[new] Typechecking for Const nodes #103
Conversation
d815034
to
640d1d5
Compare
640d1d5
to
653a366
Compare
This PR does a few things to work around the fact that a |
035215f
to
0457711
Compare
src/hugr/typecheck.rs
Outdated
check_valid_width(*width)?; | ||
// Check that the terms make sense against the types | ||
if exp_width == width { | ||
let max_value = u128::pow(2, *width as u32); |
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.
the compiler/stdlib might optimise using this anyway, but use 1<<pow
in general to do powers of two
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.
I've just updated the logic here a bit, but it seems good to me to have HugrIntValueStore::pow
when we're being generic over what output type is
src/hugr/typecheck.rs
Outdated
Err(TypeError::IntWidthMismatch(*exp_width, *width)) | ||
} | ||
} | ||
(ty @ ClassicType::F64, _) => Err(TypeError::Unimplemented(ty.clone())), |
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.
what's the trouble with floats?
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.
We don't have any float constructor for ConstValue
yet!
Co-authored-by: Seyon Sivarajah <seyon.sivarajah@quantinuum.com>
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.
Looks good, just spotted a couple of things (mainly just need to change ConstConst)
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.
🙏
Add a validation check that const values match the type of the wires coming out of them