diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 97c75e65e1d..03633a89a86 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -37,10 +37,14 @@ pub fn expand_expr(extsbox: @mut SyntaxEnv, // entry-point for all syntax extensions. expr_mac(ref mac) => { match (*mac).node { - // Token-tree macros, these will be the only case when we're - // finished transitioning. + // Token-tree macros: mac_invoc_tt(pth, ref tts) => { - assert (vec::len(pth.idents) == 1u); + if (pth.idents.len() > 1u) { + cx.span_fatal( + pth.span, + fmt!("expected macro name without module \ + separators")); + } /* using idents and token::special_idents would make the the macro names be hygienic */ let extname = cx.parse_sess().interner.get(pth.idents[0]); @@ -319,8 +323,12 @@ pub fn expand_stmt(extsbox: @mut SyntaxEnv, } _ => return orig(s, sp, fld) }; - - assert(vec::len(pth.idents) == 1u); + if (pth.idents.len() > 1u) { + cx.span_fatal( + pth.span, + fmt!("expected macro name without module \ + separators")); + } let extname = cx.parse_sess().interner.get(pth.idents[0]); let (fully_expanded, sp) = match (*extsbox).find(&extname) { None => diff --git a/src/test/compile-fail/macro-with-seps-err-msg.rs b/src/test/compile-fail/macro-with-seps-err-msg.rs new file mode 100644 index 00000000000..74c040238ac --- /dev/null +++ b/src/test/compile-fail/macro-with-seps-err-msg.rs @@ -0,0 +1,17 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// error-pattern:expected macro name without module separators + +fn main() { + globnar::brotz!(); +} + +