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

[Bug] Confusing Type Inference #2702

Open
Vipul-Cariappa opened this issue May 15, 2024 · 1 comment
Open

[Bug] Confusing Type Inference #2702

Vipul-Cariappa opened this issue May 15, 2024 · 1 comment

Comments

@Vipul-Cariappa
Copy link
Contributor

Type inference fails while converting between types and assigning.
Example

>>> x: i32 = i32("123")
semantic error: Type mismatch in annotation-assignment, the types must be compatible
 --> input:1:1
  |
1 | x: i32 = i32("123")
  | ^            ^^^^^ type mismatch ('i32' and 'str')


Note: Please report unclear or confusing messages as bugs at
https://github.com/lcompilers/lpython/issues.

But it works while printing.

❯ lp
>>> print(i32("123"))
123

Can i32 function type cast?

If someone can suggest a more meaningful title for this issue, I would appreciate it.

@certik
Copy link
Contributor

certik commented May 15, 2024

I think this might be a duplicated of #2554.

Also discussed at https://lfortran.zulipchat.com/#narrow/stream/311866-LPython/topic/Int.20to.20string.20conversion.

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

2 participants