Skip to content

Core Map.get when map has with optional values  #7054

@angusjf

Description

@angusjf

Thank you for filing! Check list:

  • Is it a bug? Usage questions should often be asked in the forum instead.
  • Concise, focused, friendly issue title & description.
  • A minimal, reproducible example.
  • OS and browser versions, if relevant.
  • Is it already fixed in master? Instructions
type key = A | B

let dict = Map.fromArray([(A, Some(1)), (B, None)])

assert(dict->Map.get(A) == Some(Some(1))) // as expected

assert(dict->Map.get(B) == None)          // expected to fail, passes

assert(dict->Map.get(B) == Some(None))    // expected to pass, fails

JS's Map returns undefined when the key is not present, and also when the value is undefined.

https://github.com/rescript-lang/experimental-rescript-stdlib-build/blob/aa8001a778a8975f83ece0a5266b3049b9d20d42/core/src/Core__Map.res#L14

Apologies if issue is in the wrong place, I am new to rescript

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions