-
-
Notifications
You must be signed in to change notification settings - Fork 320
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
Adding the decimal functions for LLVM #7261
base: main
Are you sure you want to change the base?
Conversation
Functions defined included `toDec`, `maxDec`, and `minDec`
These lines were removed, I don't know why.
@wizard7377 can you sign all of these commits? It looks like the first one got missed. We can re-approve and merge once that's done. |
Signed-off-by: Anton-4 <[email protected]>
Tomorrow I'm going to finish altering the panics check to actually show the locations of the new panics |
This problem is harder than it seems, so I searched and found cargo-scout. I forked it and adapted it for our use case but it's reporting zero new clippy errors, I did a bunch of debugging but was not yet able to figure it out, I will continue on Monday. |
Signed-off-by: Anton-4 <[email protected]>
to, | ||
"int_cast", | ||
) | ||
.unwrap(); |
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.
Can this unwrap be reasonably avoided so we don't crash the compiler with a bad error message?
use inkwell::types::BasicTypeEnum; | ||
///Change from a basic LLVM value to a Roc `Result` | ||
fn result_with<'ctx>( | ||
env: &Env<'_, 'ctx, '_>, | ||
good_type: BasicTypeEnum, | ||
good_value: impl BasicValue<'ctx>, | ||
bad_type: BasicTypeEnum, | ||
bad_value: impl BasicValue<'ctx>, | ||
) -> StructValue<'ctx> { | ||
let struct_type = env.context.struct_type(&[good_type, bad_type], false); | ||
let return_value = struct_type.const_zero(); | ||
let return_value = env | ||
.builder | ||
.build_insert_value(return_value, good_value, 0, "good_value") | ||
.unwrap(); | ||
let return_value = env | ||
.builder | ||
.build_insert_value(return_value, bad_value, 1, "is_bad") | ||
.unwrap(); | ||
|
||
return_value.into_struct_value() | ||
} |
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.
Can these unwraps be reasonably avoided so we don't crash the compiler with a bad error message?
I'm going to take two days off and I did not want to block this, so I reverted the panic check changes and shared the problematic unwraps above. |
If the unwraps can not be avoided with reasonable effort, we should use |
Adding the builtins for
maxDec
,minDec
, andtoDec
, andtoDecChecked
to the LLVM compiler, fixing #5446 and #5486 for LLVM.