Skip to content

Limit type inference to bottom up, give the literals a type. #7

Open

Description

With the choice of a post-order encoding, bottom-up typing is obvious and could be used in the binary encoding too, see WebAssembly#620

The literal constants do not have a type specifier and for bottom-up typing they need a type. There is not always a top-down type either for example (drop (i64.const 1)) is ambiguous in the text format. Could use 1L for i64 and 1F0 or 1D0 etc for the floats.

Activity

  1. qwertie commented on May 24, 2016

    @qwertie

    As I mentioned already in the comments on my PR. I don't mind type inference - it's handy and not hard to implement (and remember that we don't have the efficiency concerns here that we have in the binary format) - but we should be able to specify the type concisely. It goes without saying that the type inferred for a dropped value will have to be specified at some point, but it hardly matters. I'd say treat 1234 as an i32 until proven otherwise.

  2. sunfishcode commented on May 24, 2016

    @sunfishcode
    Owner

    This issue has surfaced in our implementation too.

    Since we have type inference for infix operators, my thought was that it'd be nice to have type inference for literals too. drop (if wasm adds that) or unused values in block-like constructs (if it doesn't), seems to be the only context where the type cannot be inferred, and that's a very uncommon case because it's trivially dead code. One idea I'm considering is an optional suffix that would be required only in otherwise ambiguous cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions