# HG changeset patch # User Aziz K?ksal # Date 1203819099 -3600 # Node ID 47c5099562c72fd310f667933754337bc14641f8 # Parent 3b34f6a95a27a3220030e349bf1f2deff59c80a1 Added two semantic error messages. diff -r 3b34f6a95a27 -r 47c5099562c7 trunk/src/dil/Messages.d --- a/trunk/src/dil/Messages.d Sun Feb 24 02:41:11 2008 +0100 +++ b/trunk/src/dil/Messages.d Sun Feb 24 03:11:39 2008 +0100 @@ -150,4 +150,6 @@ auto VariableConflictsWithDecl = "variable '{}' conflicts with declaration @{}"; auto InterfaceCantHaveVariables = "an interface can't have member variables"; auto MixinArgumentMustBeString = "the mixin argument must evaluate to a string"; + auto DebugSpecModuleLevel = "debug={} must be a module level"; + auto VersionSpecModuleLevel = "version={} must be a module level"; } diff -r 3b34f6a95a27 -r 47c5099562c7 trunk/src/dil/semantic/Pass1.d --- a/trunk/src/dil/semantic/Pass1.d Sun Feb 24 02:41:11 2008 +0100 +++ b/trunk/src/dil/semantic/Pass1.d Sun Feb 24 03:11:39 2008 +0100 @@ -72,6 +72,12 @@ scop = scop.exit(); } + /// Returns true if this is the module scope. + bool isModuleScope() + { + return scop.symbol.isModule(); + } + /// Insert a symbol into the current scope. void insert(Symbol symbol, Identifier* name) { @@ -352,7 +358,9 @@ { if (d.isSpecification) { - if (d.spec.kind == TOK.Identifier) + if (!isModuleScope()) + error(d.begin, MSG.DebugSpecModuleLevel, d.spec.srcText); + else if (d.spec.kind == TOK.Identifier) context.addDebugId(d.spec.ident.str); else context.debugLevel = d.spec.uint_; @@ -372,7 +380,9 @@ { if (d.isSpecification) { - if (d.spec.kind == TOK.Identifier) + if (!isModuleScope()) + error(d.begin, MSG.VersionSpecModuleLevel, d.spec.srcText); + else if (d.spec.kind == TOK.Identifier) context.addVersionId(d.spec.ident.str); else context.versionLevel = d.spec.uint_;