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

Small inconsistency in target strings #3826

Open
GearsDatapacks opened this issue Nov 13, 2024 · 4 comments · May be fixed by #3851
Open

Small inconsistency in target strings #3826

GearsDatapacks opened this issue Nov 13, 2024 · 4 comments · May be fixed by #3851
Labels
good first issue Good for newcomers help wanted Contributions encouraged priority:medium

Comments

@GearsDatapacks
Copy link
Member

GearsDatapacks commented Nov 13, 2024

In Gleam v1.6.0-rc-1, the following code is valid and compiles:

@target(js)
fn wibble() {
  todo
}

But this doesn't:

@external(js, "./wibble.mjs", "wobble")
fn wibble() -> Nil

The shorthands, js and erl are allowed in various places such as @target and the --target flag for gleam build and gleam run. However, they are not allowed in @external. Small point, but I would expect the same set of values to be accepted in all such places.

@GearsDatapacks
Copy link
Member Author

This inconsistency occurs because the parsing of @target uses Target's FromStr implementation, but @external explicitly matches on the possible string values.

@lpil
Copy link
Member

lpil commented Nov 13, 2024

Let's deprecate the target one.

@lpil lpil added help wanted Contributions encouraged good first issue Good for newcomers priority:medium labels Nov 13, 2024
@giacomocavalieri
Copy link
Member

If we're to deprecate it we could also make the formatter rewrite @target(js) to @target(javascript) and same for erl

@GearsDatapacks
Copy link
Member Author

GearsDatapacks commented Nov 14, 2024

It already does!

@GearsDatapacks GearsDatapacks linked a pull request Nov 19, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Contributions encouraged priority:medium
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants