Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
mooreryan opened this issue Oct 23, 2024 · 1 comment
Closed

Comments

@mooreryan
Copy link

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)

@lpil
Copy link
Owner

lpil commented Oct 24, 2024

Oh how awful, I'm sorry about this!

@lpil lpil closed this as completed Oct 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants