-
Notifications
You must be signed in to change notification settings - Fork 5
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
base: master
Are you sure you want to change the base?
Ranged Integers #66
Conversation
BinaryOperator::Lesser => ( | ||
(self.new_int_type(), self.new_int_type()), | ||
BOOL_CONCRETE_TYPE, | ||
), |
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 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( |
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.
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() |
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.
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) |
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.
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 |
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.
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))?; |
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.
You should add the field names. Actually, there is a function that does this already: pretty_print_concrete_instance
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.
Where do I get the &LinkInfo
from? Should it be added to the display proxy?
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.
?
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.
&self.linker_types[global_ref.id].link_info
pub fn try_fully_substitute( | ||
&self, | ||
substitutor: &TypeSubstitutor<Self, ConcreteTypeVariableIDMarker>, | ||
) -> Option<Self> { |
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.
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
src/typing/type_inference.rs
Outdated
assert!(*na == *nb); | ||
UnifyResult::Success | ||
assert!(na.template_args.len() == nb.template_args.len()); | ||
zip(na.template_args.iter(), nb.template_args.iter()) |
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.
Use crate::alloc::zip_eq
here
} | ||
}; | ||
let mut template_args: FlatAlloc<ConcreteType, TemplateIDMarker> = FlatAlloc::new(); | ||
template_args.alloc(ConcreteType::new_int(out_size)); |
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.
Could be combined with ConcreteType::new_int_type
src/instantiation/mod.rs
Outdated
@@ -426,3 +426,9 @@ fn perform_instantiation( | |||
|
|||
context.extract() | |||
} | |||
|
|||
impl InstantiationContext<'_, '_> { | |||
pub fn new_int_type(&self) -> ConcreteType { |
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.
Redundant
Add test cases |
Add types to in code values / constants |
Cast module |
Close #28