diff --git a/src/res_core.ml b/src/res_core.ml index 5a3b180d..628a8270 100644 --- a/src/res_core.ml +++ b/src/res_core.ml @@ -3782,7 +3782,7 @@ and parseAtomicTypExpr ~attrs p = and parsePackageType ~startPos ~attrs p = let modTypePath = parseModuleLongIdent ~lowercase:true p in begin match p.Parser.token with - | With -> + | Lident "with" -> Parser.next p; let constraints = parsePackageConstraints p in let loc = mkLoc startPos p.prevEndPos in @@ -5769,7 +5769,7 @@ and parseFunctorModuleType p = and parseWithConstraints moduleType p = match p.Parser.token with - | With -> + | Lident "with" -> Parser.next p; let first = parseWithConstraint p in let rec loop p acc = diff --git a/src/res_token.ml b/src/res_token.ml index d49092f3..a14491dd 100644 --- a/src/res_token.ml +++ b/src/res_token.ml @@ -55,7 +55,6 @@ type t = | Include | Module | Of - | With | Land | Lor | Band (* Bitwise and: & *) | BangEqual | BangEqualEqual @@ -143,7 +142,6 @@ let toString = function | Include -> "include" | Module -> "module" | Of -> "of" - | With -> "with" | Lor -> "||" | Band -> "&" | Land -> "&&" | BangEqual -> "!=" | BangEqualEqual -> "!==" @@ -191,7 +189,6 @@ let keywordTable = function | "type" -> Typ | "when" -> When | "while" -> While -| "with" -> With | _ -> raise Not_found [@@raises Not_found] @@ -199,7 +196,7 @@ let isKeyword = function | And | As | Assert | Constraint | Else | Exception | Export | External | False | For | If | Import | In | Include | Land | Lazy | Let | List | Lor | Module | Mutable | Of | Open | Private | Rec - | Switch | True | Try | Typ | When | While | With -> true + | Switch | True | Try | Typ | When | While -> true | _ -> false let lookupKeyword str = diff --git a/tests/parsing/grammar/expressions/__snapshots__/parse.spec.js.snap b/tests/parsing/grammar/expressions/__snapshots__/parse.spec.js.snap index c765d39e..9a942a31 100644 --- a/tests/parsing/grammar/expressions/__snapshots__/parse.spec.js.snap +++ b/tests/parsing/grammar/expressions/__snapshots__/parse.spec.js.snap @@ -531,7 +531,8 @@ let x = _ident_ident let x = _ident_ident_ let x = __ident__ let x = list -let x = Foo.Bar.list" +let x = Foo.Bar.list +let with = with" `; exports[`if.js 1`] = ` diff --git a/tests/parsing/grammar/expressions/ident.js b/tests/parsing/grammar/expressions/ident.js index 8f045aa4..41ee4a20 100644 --- a/tests/parsing/grammar/expressions/ident.js +++ b/tests/parsing/grammar/expressions/ident.js @@ -9,3 +9,5 @@ let x = __ident__ let x = list let x = Foo.Bar.list + +let with = with