Skip to content

Inconsistent behavior for envoy.get between Erlang and JS targetsΒ #3

@mooreryan

Description

@mooreryan

Expected return value according to type annotations is Result(String, Nil)

pub fn get(name: String) -> Result(String, Nil)

Erlang matches that:

false -> {error, nil};

JS has a string value rather than nil:

return new GError("Key not found");

Neither one is favored in the tests as they both use the _ match:

let assert Error(_) = envoy.get("UAGE")

let assert Error(_) = envoy.get("UAGE")

The Result(String, Nil) is probably the desired behavior as it matches dict.get:

https://github.com/gleam-lang/stdlib/blob/341a71049ad765f8788af497969efbb94aba0bab/src/gleam/dict.gleam#L152-L152

What do you think?

(Related to the test failure on the gleam cookbook: gleam-lang/cookbook#20)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions