[nem-bug] [Nemerle 0000644]: Wrong behavior during base ctor call
feedback at nemerle.org
feedback at nemerle.org
Mon Apr 3 15:11:31 CEST 2006
A NOTE has been added to this issue.
======================================================================
<http://nemerle.org/bugs/view.php?id=644>
======================================================================
Reported By: VladD2
Assigned To:
======================================================================
Project: Nemerle
Issue ID: 644
Category: Compiler
Reproducibility: always
Severity: minor
Priority: normal
Status: new
======================================================================
Date Submitted: 04-02-2006 21:53 CEST
Last Modified: 04-03-2006 15:11 CEST
======================================================================
Summary: Wrong behavior during base ctor call
Description:
This code:
using System.Console;
class A
{
public this() { WriteLine("A()"); }
}
class B : A
{
public this()
{
WriteLine("B()");
base();
}
}
def b = B();
print:
A()
B()
A()
i.e. occur unnecessary ctor call.
In the more complex case:
class A
{
public this(_ : int) { WriteLine("A()"); }
}
class B : A
{
public this(_ : int)
{
WriteLine("B()");
base(2);
}
}
def b = B(1);
ncc generate error:
test-016.n:12:3:15:4: error: wrong number of parameters in call, needed 1,
got 0
test-016.n:12:3:15:4: error: typing error in call
======================================================================
----------------------------------------------------------------------
nazgul - 04-02-06 23:21
----------------------------------------------------------------------
I guess there is some restriction in IL where base call should occur. In C#
there is even a special syntax, which will not allow to execute arbitrary
code before base call.
Compiler should probably report an error about usage of base not on the
beginning of constructor, but it is not clear for me why for example
base(x + 3 + f()) is allowed, but a sequence of statements isn't.
----------------------------------------------------------------------
VladD2 - 04-03-06 15:05
----------------------------------------------------------------------
I've created a C#-sample, where were 2 classes, one of them inherited from
another. Constructors of those classes print to console the information
about constructor calls. Then I decompiled the resulting assembly into IL
(by ILDASM), commented out the call of base class constructor and compiled
with ILASM. The compilation was successful, and execution of the result
assembly printed out only the information about the call of the inherited
class.
So, there are no "physical" problems in IL, preventing the realization of
correct behaviour.
It's rather serious problem, and I think it needs an urgent correction.
----------------------------------------------------------------------
nazgul - 04-03-06 15:11
----------------------------------------------------------------------
Did you run verifier on the resulting assebly (PEVerify.exe from SDK)
Issue History
Date Modified Username Field Change
======================================================================
04-02-06 21:53 VladD2 New Issue
04-02-06 23:21 nazgul Note Added: 0001139
04-03-06 15:05 VladD2 Note Added: 0001141
04-03-06 15:11 nazgul Note Added: 0001143
======================================================================
More information about the bugs
mailing list