Repository navigation
Highlight named funs called _, fix README and test record field types - #22
Merged
Merged
Conversation
The snapshot tests run with the Markdown stand-in grammar since the doc-directive fix, but the update command in the README did not load it. Running it as documented rewrote the docstring and sigil snapshots with doc attributes scoped as generic directives.
A named fun can be called `_`, but the name patterns required at least
one character after a leading underscore. A lone `_` name was not
recognised, so with a `/` later on the same line the implicit fun rule
took over, ended at the `/` and left `end` outside the fun:
fun _(A) -> A / 2 end
Accept `_` as a name in the named fun rule and in the clause name
patterns of the fun expression rules.
A typed record field is scoped meta.type.erlang from its `::` to the comma or brace that ends the field. Add tests showing that a comma nested in the type (in a tuple, a fun type or a binary) does not end the region early, and that a default value, which Erlang writes before the `::`, stays an expression.
meta-codesync Bot
pushed a commit
to WhatsApp/erlang-language-platform
that referenced
this pull request
Sep 30, 2026
Summary: Sync both copies of the Erlang TextMate grammar (the ELP extension and the internal `nuclide.erlang` extension) with https://github.com/erlang-ls/grammar at `49f7a9a`. Both copies now match upstream byte for byte. Changes since the last sync: - erlang-ls/grammar#19: named fun expressions (`fun Name(...) -> ... end`) are highlighted correctly, and no longer scope the rest of the file as an implicit fun. Zero-arity fun expressions such as `fun() -> ok end` are keywords instead of function types. The function type rule now only applies inside types (`-type`, `-opaque`, `-spec`, `-callback`, typed record fields), via a new `meta.type.erlang` scope. Fixes pgourlain/vscode_erlang#316 and #317. - erlang-ls/grammar#20: a fun type after a top-level range (`-type t() :: 1..10 | fun(() -> ok).`) or in a `-nominal` type no longer scopes the rest of the file as a fun expression. - erlang-ls/grammar#21: upstreams the fix for Markdown leaking out of `-doc`/`-moduledoc` attributes (D98300495), which only lived in these copies. No behaviour change here. - erlang-ls/grammar#22: follow-ups from the review of this diff. Named funs called `_` (`fun _(A) -> A end`) are highlighted as named funs. `README.md` typos fixed (`ignode`, `./test/snap`) and the snapshot update command loads the Markdown test grammar. Upstream also adds tests showing that a comma nested in a record field type does not end the `meta.type.erlang` region, and that a default value stays an expression. `README.md` is synced too (test instructions and references); `LICENSE` is unchanged. Reviewed By: jcpetruzza Differential Revision: D122532634 fbshipit-source-id: cabfee7809fcd0e0977d700bc71b8b50db8cd02f
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-ups from syncing the grammar into the ELP VS Code extension, where a review turned up a few issues.
Highlight named funs called
_A named fun can be called
_, but the name patterns required at least one character after a leading underscore. With a/later on the same line, the implicit fun rule took over, ended at the/and leftendoutside the fun:_is now accepted as a name in the named fun rule and in the clause name patterns of the fun expression rules.Test where record field types start and end
No grammar change. A typed record field is scoped
meta.type.erlangfrom its::to the comma or brace that ends the field. The new tests show that a comma nested in the type (in a tuple, a fun type or a binary) doesn't end the region early, and that a default value, which Erlang writes before the::, stays an expression:README fixes
ignode→ignore)../test/snap→./tests/snap).docstringandsigilsnapshots with doc attributes scoped as generic directives.Tests
npm testpasses. The new tests for named funs called_fail without the fix.