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 11 commits into
base: master
Choose a base branch
from
Open

Ranged Integers #66

wants to merge 11 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.

src/to_string.rs Outdated
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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ok I have implemented that now but is there a reason pretty_print_concrete_instance does not return a impl Display but a String? Thats the exact issue display proxys where meant to solve.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I guess where I used it, it's for setting the name field of link_info, which is a String. But having it return impl Display would be more general.

}
};
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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

How exactly? Would I call TypeSubstitutor::new_int_type and unify the unknown from the template args with the expected size?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I meant that new_int_type could itself use new_int. But maybe combining them reduces usability. Perhaps a rename of new_int_type to new_unknown_int would be opportune

@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

@IBims1NicerTobi
Copy link
Collaborator Author

Fix this:

Error: Failed to Typecheck Named(ConcreteGlobalReference { id: type_1, template_args: [Unknown(concrete_type_variable_1)] }) = Named(ConcreteGlobalReference { id: type_1, template_args: [Unknown(concrete_type_variable_1)] }) + Named(ConcreteGlobalReference { id: type_1, template_args: [Unknown(concrete_type_variable_5)] })
    ╭─[/home/tobias/.sus/0.2.0-devel/std/util.sus:91:11]
    │
 91 │        value = value + 1
    │                ────┬────
    │                    ╰────── Failed to Typecheck Named(ConcreteGlobalReference { id: type_1, template_args: [Unknown(concrete_type_variable_1)] }) = Named(ConcreteGlobalReference { id: type_1, template_args: [Unknown(concrete_type_variable_1)] }) + Named(ConcreteGlobalReference { id: type_1, template_args: [Unknown(concrete_type_variable_5)] })
────╯

@VonTum
Copy link
Collaborator

VonTum commented Mar 11, 2025

Fix this:

Error: Failed to Typecheck Named(ConcreteGlobalReference { id: type_1, template_args: [Unknown(concrete_type_variable_1)] }) = Named(ConcreteGlobalReference { id: type_1, template_args: [Unknown(concrete_type_variable_1)] }) + Named(ConcreteGlobalReference { id: type_1, template_args: [Unknown(concrete_type_variable_5)] })
    ╭─[/home/tobias/.sus/0.2.0-devel/std/util.sus:91:11]
    │
 91 │        value = value + 1
    │                ────┬────
    │                    ╰────── Failed to Typecheck Named(ConcreteGlobalReference { id: type_1, template_args: [Unknown(concrete_type_variable_1)] }) = Named(ConcreteGlobalReference { id: type_1, template_args: [Unknown(concrete_type_variable_1)] }) + Named(ConcreteGlobalReference { id: type_1, template_args: [Unknown(concrete_type_variable_5)] })
────╯

Well it seems that that on its own should never typecheck. Rather either the user should specify a cast, or add a % max_val

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