[svn] r7741: nemerle/trunk/ncc: generation/Typer3.n
testsuite/negative/bug-664.n
divan
svnadmin at nemerle.org
Fri Jul 6 21:10:44 CEST 2007
Log:
Deny method call before base constructor call.
Author: divan
Date: Fri Jul 6 21:10:37 2007
New Revision: 7741
Modified:
nemerle/trunk/ncc/generation/Typer3.n
nemerle/trunk/ncc/testsuite/negative/bug-664.n
Modified: nemerle/trunk/ncc/generation/Typer3.n
==============================================================================
--- nemerle/trunk/ncc/generation/Typer3.n (original)
+++ nemerle/trunk/ncc/generation/Typer3.n Fri Jul 6 21:10:37 2007
@@ -1403,8 +1403,8 @@
Message.Warning ($"Base constructor call can happen $y times");
}
//Check this usage before base()
- //Allow this.*
- //Deny base.*, this, base
+ //Allow this.field
+ //Deny base.*, this.method, this, base
def f (_) {
| TExpr.Call (e, p, _) when IsCtor (e)
=> _ = List.Map (p, x => ctor_calls (x.expr));
@@ -1415,9 +1415,12 @@
"using base class field before base is constructed");
Some (false)
| TExpr.MethodRef (e, m, _, _) as expr when IsThis (e)
- => when (IsBaseMethod (m))
+ => if (IsBaseMethod (m))
Message.Error (expr.loc,
"using base class method before base is constructed");
+ else
+ Message.Error (expr.loc,
+ "using class method before base is constructed (``this'' isn't yet initialized)");
Some (false)
| e when IsThis (e)
=> Message.Error (e.loc,
Modified: nemerle/trunk/ncc/testsuite/negative/bug-664.n
==============================================================================
--- nemerle/trunk/ncc/testsuite/negative/bug-664.n (original)
+++ nemerle/trunk/ncc/testsuite/negative/bug-664.n Fri Jul 6 21:10:37 2007
@@ -35,7 +35,7 @@
_ = this.x;
System.Console.WriteLine ($"base.x = $(base.x)"); // E: using base class field before base is constructed
_ = base.y (); // E: using base class method before base is constructed
- _ = this.y ();
+ _ = this.y (); // E: using class method before base is constructed
base (1);
More information about the svn
mailing list