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

Allow primitives/literals to unify regardless of their mutability #342

Open
kevinbarabash opened this issue Aug 17, 2024 · 0 comments
Open

Comments

@kevinbarabash
Copy link
Contributor

Mutable function params gets a little wonky with generic type because you could have something like:

fn foo<T>(mut x: T) { ... }

Since primitive types like string, number, etc. are immutable the type system will complain if you try to do:

let bar = 5;
foo(bar); // error, can't pass immutable argument to mutable param

This should be allowed though since primitives/literals can never be mutated (although a mutable variable whose type is a primitive can be re-assigned to another inhabitant of primitive type).

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

No branches or pull requests

1 participant