dylan-lang/opendylan — Issue #112: compiler dies on valid Dylan code
Author: hannesm
Created: 2011-12-15 06:01:09+00:00
State: open

or, the so-called-bug7405 issue, which I promised to fix since years...
here's the code (degenerated from doctower):

```` dylan

define function seq1 (#rest sub-rules) => (rule-parser :: )
end;

define function parse-ablock (stream, context)
let prod = ablock-parser-rule (stream, context); // [1]
prod := #f; // [2]
end function;

define constant program-parser-rule = seq1(parse-ablock); // [3]

define constant ablock-parser-rule = seq1(parse-ablock);

/*
It compiles if you change line 1 to use program-parser-rule.
It compiles if you delete line 2.
It compiles if you delete line 3.
It compiles if seq1 doesn't take an argument

So, we end in recursion between conversion and optimization (conversion
translates the parsed dylan code into the intermediate representation, called
DFM). During conversion of constants, these are tried to be evaluated,
triggering optimization. Thus,
program-parser-rule
triggers parse-ablock
triggers ablock-parser-rule
triggers parse-ablock (dup) finishes
UPGRADE seq1 finishes
finishes
does again conversion + half optimization
finishes
*/
````