Skip to content
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

Open
wants to merge 24 commits into
base: main
Choose a base branch
from

Conversation

wizard7377
Copy link
Contributor

@wizard7377 wizard7377 commented Nov 28, 2024

Adding the builtins for maxDec, minDec, and toDec, and toDecChecked to the LLVM compiler, fixing #5446 and #5486 for LLVM.

@wizard7377 wizard7377 changed the title Adding the decimal functions Adding the decimal functions for LLVM Dec 1, 2024
@wizard7377 wizard7377 marked this pull request as ready for review December 1, 2024 20:04
@smores56
Copy link
Collaborator

@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.

@Anton-4
Copy link
Collaborator

Anton-4 commented Dec 20, 2024

Tomorrow I'm going to finish altering the panics check to actually show the locations of the new panics

@Anton-4
Copy link
Collaborator

Anton-4 commented Dec 21, 2024

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.

to,
"int_cast",
)
.unwrap();
Copy link
Collaborator

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?

Comment on lines +3008 to +3029
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()
}
Copy link
Collaborator

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?

@Anton-4
Copy link
Collaborator

Anton-4 commented Dec 23, 2024

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.

@Anton-4
Copy link
Collaborator

Anton-4 commented Dec 23, 2024

If the unwraps can not be avoided with reasonable effort, we should use expect with a nice error message.
Me, Luke or Richard will need to forge the merge in case expect is used.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants