Skip to content

Disallow all implicit casting #1006

Open
@certik

Description

@certik

We should disallow all implicit casting. In particular, this should not work anymore:

x: f64
y: f32
y = 1.0
x = y

Rather, one would need to do x = f64(y). If there is a better way for the syntax of these casts, we could use it, but the f64(y) might work both in CPython and LPython.

The tricky part is what to do with constants. I think integers like 3 should be i32 and floats like 3.0 should be f64.

Then how to do:

x: f32 = 3.0

Here we could do:

x: f32 = f32(3.0)

And the same for:

n: i64 = i64(3)

I am thinking let's start with this approach. We can always relax these restrictions later in a backwards compatible manner, but it's hard to put them back on without breaking people's codes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    could closeIssues/PRs which can be closed.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions