Skip to content

Reunify Param and Local Values #10

@morgankenyon

Description

@morgankenyon

In this commit: c5a07cd

I changed from storing the function parameters and local variables in the same data structure to be stored in two separate data structures.

I did this due to F#'s Unit type. Unit indicates no parameters, so when I compile to Wasm I drop it.

So a F# function with 1 Unit parameter becomes a Wasm function with no parameters.

When getting index, I didn't want to remove the Unit parameters, then count.

But this causes issues since Wasm index of params spans both params and locals.

So the following snippet:

let countTo (n) =
    let mutable x = 0
    while x < n do
        x <- x + 1
    x

We have the following variables:

  • 1 function parameter - n
    • Index of n = 0
  • 1 local variable - x
    • Index of x = 1

Since they're being stored separately, the index of x is turning 0.

I'm putting a temporary fix in place, but probably something I need to revisit.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions