Merge pull request #294 from ahmedcharles/pubmacro

Add error when macros are marked public.
This commit is contained in:
Niko Matsakis 2018-01-30 09:05:47 -05:00 committed by GitHub
commit 6a48b9f070
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 1 deletions

View File

@ -124,6 +124,9 @@ impl<'grammar> Validator<'grammar> {
}
}
GrammarItem::Nonterminal(ref data) => {
if data.public && !data.args.is_empty() {
return_err!(data.span, "macros cannot be marked public");
}
let inline_annotation = intern(INLINE);
let known_annotations = vec![inline_annotation];
let mut found_annotations = set();

View File

@ -125,4 +125,12 @@ fn mixing_names_and_anonymous_values() {
r#"anonymous symbols like this one cannot be combined with named symbols like `b:B`"#,
r#"grammar; Term = { <A> <b:B> => Alien: Eighth passanger of Nostromo};"#,
r#" ~~~ "#);
}
}
#[test]
fn public_macros() {
check_err(
r#"macros cannot be marked public"#,
r#"grammar; pub Comma<T> = (T ",")* T?;"#,
r#" ~~~~~~~~ "#);
}