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

Manually annotated types on assignments don't show up in generated code #26

Open
ameliatastic opened this issue Oct 17, 2022 · 1 comment
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@ameliatastic
Copy link
Owner

ameliatastic commented Oct 17, 2022

When adding a type annotation on an assignment, the annotation is only used for the Seahorse type checker.

-- This Seahorse code:
n = 1
m: u64 = 2
-- Turns into roughly this Rust code:
let mut n = 1;
let mut m = 2;

This leads to unintuitive bugs popping up when you try to use a type annotation to solve a compilation error:

-- This Seahorse code:
n = 10**2
-- Turns into this Rust code, which fails to compile because .pow() is not defined on arbitrary integers:
let mut n = 10.pow(2);

-- Intuitively, you might try to fix the code in one of these two ways, but both will fail because the
-- generated code doesn't care about the type annotation:
n1: u64 = 10**2

b: u64 = 10
n2 = b**2

To prevent this issue, type annotations in Seahorse should lead to type annotations in the generated Rust code.

@ameliatastic ameliatastic added bug Something isn't working good first issue Good for newcomers labels Oct 17, 2022
@ameliatastic ameliatastic moved this from Todo to In Progress in Seahorse Nov 21, 2022
@kubanemil
Copy link

Is this problem still relevant?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
Status: In Progress
Development

No branches or pull requests

2 participants