rsdn/nemerle — Issue #281: No constant folding in code generated by macros
Author: CodingUnit
Created: 2012-02-04 15:19:13+00:00
State: open

This code generates redundant code in IL:

```nemerle
// in macro library
macro factorial(n : int)
{
if (n == 0) <[ 1 ]> else <[ $n * factorial($(n - 1)) ]>
}

// console sample, reference to macro
using System;
using System.Console;

module Test
{
Main() : void
{
WriteLine(factorial(5));
_ = ReadLine();
}
}
```

IL code:
```
Console.WriteLine((int) (5 * (4 * (3 * (2 * (1 * 1))))));
```
But this constants need to evaluate to one constant value