Skip to content

Issue in untagged variants with both an object and an array. #6207

Closed
@cristianoc

Description

@cristianoc

This is OK:

  type t = | Array(array<int>) | Record({x:int})

But this is wrong:

@unboxed
type t = Record({x: int}) | Array(array<int>)

let classify = v =>
  switch v {
  | Record({x}) => x
  | Array(a) => a[0]
  }
function classify(v) {
  if (typeof v === "object") {
    return v.x;
  } else {
    return Caml_array.get(v, 0);
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions