[nem-bug] [Nemerle 0001040]: Invalid IL generated by block return
feedback at nemerle.org
feedback at nemerle.org
Sat Oct 20 19:10:55 CEST 2007
The following issue has been RESOLVED.
======================================================================
<http://nemerle.org/bugs/view.php?id=1040>
======================================================================
Reported By: Evin Robertson
Assigned To: divan
======================================================================
Project: Nemerle
Issue ID: 1040
Category: Compiler
Reproducibility: always
Severity: major
Priority: normal
Status: resolved
Resolution: fixed
Fixed in Version:
======================================================================
Date Submitted: 08-18-2007 03:41 CEST
Last Modified: 10-20-2007 19:10 CEST
======================================================================
Summary: Invalid IL generated by block return
Description:
The following program generates invalid IL. I think the problem is the
unneeded initial ldarg.1
public class InvalidBlockReturn
{
private static F(x : int, z : ref int) : int
{
result:
{
z = match(x)
{
| 0 =>
result(5)
| _ =>
x
}
F(x-1, ref z)
}
}
public static Main(_ : array[string]) : void
{
mutable z;
System.Console.WriteLine(F(2, ref z).ToString())
}
}
I can work around it by declaring a temporary variable to hold the result
of the match and then assigning it to z.
======================================================================
----------------------------------------------------------------------
divan - 10-20-07 19:10
----------------------------------------------------------------------
Fixed on r7819.
It's compile error now, use temporary variable ;)
A bit more about changes:
- now it's wrong to write return/block return as a last statement in
block, it actually doesn't make much sense
- you can't return in the middle of assignment or another expression
(earlier assignment was an exception, as we can see it's not too cool)
- Wrong return can result in type errors, not "don't use return here",
it's sad
- documentation needs to be fixed, i'll update it soon
Issue History
Date Modified Username Field Change
======================================================================
08-18-07 03:41 Evin Robertson New Issue
10-18-07 19:57 divan Issue Monitored: divan
10-19-07 18:42 divan Status new => assigned
10-19-07 18:42 divan Assigned To => divan
10-20-07 19:10 divan Note Added: 0001971
10-20-07 19:10 divan Status assigned => resolved
10-20-07 19:10 divan Resolution open => fixed
10-20-07 19:10 divan Description Updated
10-20-07 19:10 divan Additional Information Updated
======================================================================
More information about the bugs
mailing list