浏览代码

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

Dan Korostelev 5 年之前
父节点
当前提交
ff780fb18a
共有 1 个文件被更改,包括 2 次插入0 次删除
  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 Macro,p); l = parse_common_flags >] -> (DMacro,p) :: l
 	| [< '(Kwd Dynamic,p); l = parse_common_flags >] -> (DDynamic,p) :: l
 	| [< '(Kwd Dynamic,p); l = parse_common_flags >] -> (DDynamic,p) :: l
 	| [< '(Kwd Inline,p); l = parse_common_flags >] -> (DInline,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 =
 and parse_meta_argument_expr s =