Skip to content

In module declaration treat M = { as if it were M : { #7527

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

Merged
merged 1 commit into from
May 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@
- Remove deprecated pipe last (`|>`) syntax. https://github.com/rescript-lang/rescript/pull/7512
- Improve error message for pipe (`->`) syntax. https://github.com/rescript-lang/rescript/pull/7520
- Improve a few error messages around various subtyping issues. https://github.com/rescript-lang/rescript/pull/7404
- In module declarations, accept the invalid syntax `M = {...}` and format it to `M : {...}`. https://github.com/rescript-lang/rescript/pull/7527

#### :house: Internal

- Refactor the ast for record expressions and patterns. https://github.com/rescript-lang/rescript/pull/7528

# 12.0.0-alpha.13
Expand Down
11 changes: 8 additions & 3 deletions compiler/syntax/src/res_core.ml
Original file line number Diff line number Diff line change
Expand Up @@ -6541,10 +6541,15 @@ and parse_module_declaration_or_alias ~attrs p =
| Colon ->
Parser.next p;
parse_module_type p
| Equal ->
| Equal -> (
Parser.next p;
let lident = parse_module_long_ident ~lowercase:false p in
Ast_helper.Mty.alias lident
match p.Parser.token with
| Lbrace ->
(* Parse `module M = {` as `module M : {` *)
parse_module_type p
| _ ->
let lident = parse_module_long_ident ~lowercase:false p in
Ast_helper.Mty.alias lident)
| token ->
Parser.err p (Diagnostics.unexpected token p.breadcrumbs);
Recover.default_module_type ()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,8 @@ module LongNaaaaame: MyModule

@attr
module LinkedList: module type of List

// turn `=` into `:`
module M: {
let x: int
}
3 changes: 3 additions & 0 deletions tests/syntax_tests/data/printer/signature/module.resi
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,6 @@ module LongNaaaaame: MyModule

@attr
module LinkedList: module type of List

// turn `=` into `:`
module M = { let x: int }
Loading