Browse Source

better error messages for module-level `public` and `static`

Dan Korostelev 5 years ago
parent
commit
ff780fb18a
1 changed files with 2 additions and 0 deletions
  1. 2 0
      src/syntax/grammar.mly

+ 2 - 0
src/syntax/grammar.mly

@@ -511,6 +511,8 @@ and parse_common_flags = parser
 	| [< '(Kwd Macro,p); l = parse_common_flags >] -> (DMacro,p) :: l
 	| [< '(Kwd Dynamic,p); l = parse_common_flags >] -> (DDynamic,p) :: l
 	| [< '(Kwd Inline,p); l = parse_common_flags >] -> (DInline,p) :: l
+	| [< '(Kwd Public,p); l = parse_common_flags; s >] -> syntax_error (Custom "public modifier is not supported for module-level declarations") ~pos:(Some p) s l
+	| [< '(Kwd Static,p); l = parse_common_flags; s >] -> syntax_error (Custom "static modifier is not supported for module-level declarations") ~pos:(Some p) s l
 	| [< >] -> []
 
 and parse_meta_argument_expr s =