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

Ranged Integers #66

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open

Ranged Integers #66

wants to merge 10 commits into from

Conversation

IBims1NicerTobi
Copy link
Collaborator

Close #28

@IBims1NicerTobi IBims1NicerTobi self-assigned this Feb 18, 2025
BinaryOperator::Lesser => (
(self.new_int_type(), self.new_int_type()),
BOOL_CONCRETE_TYPE,
),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder, it's not something that should concern us too badly, but maybe the boolean comparison ops should unify(left, right). Maybe, maybe not.

}

impl BinaryOpTypecheckConstraint {
fn new(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redundant

impl DelayedConstraint<InstantiationContext<'_, '_>> for BinaryOpTypecheckConstraint {
fn try_apply(&mut self, context: &mut InstantiationContext<'_, '_>) -> DelayedConstraintStatus {
if context.wires[self.left].typ.contains_unknown()
|| context.wires[self.right].typ.contains_unknown()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You must call typ.fully_substitute() before you can call contains_unknown(). unify doesn't actually change the ConcreteType objects, it only changes the state of the TypeUnifier by adding to the substitution list

}
let left_complete_type = context.wires[self.left]
.typ
.try_fully_substitute(&context.type_substitutor)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I see you're already doing a try_fully_substitute here. Then returning NoProgress should be when this returns None.

fn report_could_not_resolve_error(&self, context: &InstantiationContext<'_, '_>) {
let message = format!(
"Failed to Typecheck {:?} = {:?} {} {:?}",
self.out, self.right, self.op, self.left
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should fully_substitute these, and ignore the return code. Otherwise this will just print type_variable_xyz

ConcreteType::Named(global_ref) => {
f.write_str(&self.linker_types[global_ref.id].link_info.get_full_name())?;
for template_arg in global_ref.template_args.iter() {
write!(f, "{}", template_arg.1.display(self.linker_types))?;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should add the field names. Actually, there is a function that does this already: pretty_print_concrete_instance

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where do I get the &LinkInfo from? Should it be added to the display proxy?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

&self.linker_types[global_ref.id].link_info

pub fn try_fully_substitute(
&self,
substitutor: &TypeSubstitutor<Self, ConcreteTypeVariableIDMarker>,
) -> Option<Self> {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This implementation is incorrect. contains_unknown just checks this ConcreteType object, not the substituted version. You should base your return value on the boolean returned by fully_substitute

assert!(*na == *nb);
UnifyResult::Success
assert!(na.template_args.len() == nb.template_args.len());
zip(na.template_args.iter(), nb.template_args.iter())
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use crate::alloc::zip_eq here

}
};
let mut template_args: FlatAlloc<ConcreteType, TemplateIDMarker> = FlatAlloc::new();
template_args.alloc(ConcreteType::new_int(out_size));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be combined with ConcreteType::new_int_type

@@ -426,3 +426,9 @@ fn perform_instantiation(

context.extract()
}

impl InstantiationContext<'_, '_> {
pub fn new_int_type(&self) -> ConcreteType {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redundant

@IBims1NicerTobi
Copy link
Collaborator Author

Add test cases

@IBims1NicerTobi
Copy link
Collaborator Author

Add types to in code values / constants

@IBims1NicerTobi
Copy link
Collaborator Author

Cast module

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.

Ranged Integers
2 participants