cmajor-lang/cmajor

«Internal compiler error: "createCast:1075"» with nested graph.

Closed this issue · 2 comments

Reproduction

Given the following patch:

graph Main [[main]]
{    
    output stream float<2> out;
    node osc = StereoOsc;
    connection osc -> out;
}

graph StereoOsc 
{
    input osc.foo;
    output stream float<2> out;

    node osc = Oscillator[2];

    connection float<2> ( osc[0].out, osc[1].out ) -> out;
}

processor Oscillator
{
    input value float foo;
    output stream float out;

    let frequency = 200.0f;

    void main ()
    {
        let phaseDelta = processor.id * float (frequency * processor.period * twoPi);

        loop
        {
            out <- volume * sin (phase);
            phase = addModulo2Pi (phase, phaseDelta);
            advance();
        }
    }

    let volume = 0.15f;
    float phase;
}

running it via cmaj play or the VScode host gives the error:

Internal compiler error: "createCast:1075"

Note: the underlying error here is mine. At line 10 I’m trying to hoist a property on osc, and osc is an array. Cmaj tries to make this an array of endpoints, and that’s not supported.

Workarounds

If the graph is not nested (that is, if StereoOsc is [[main]]), the error is reported correctly:

error: Language feature not yet implemented: top-level arrays of inputs!

It’s only if StereoOsc is referenced from somewhere else that the internal error crops up.

Priority

Very low. The internal error is really only getting in the way of better verbiage to help me diagnose my syntax error. Still, it’s an exposed internal error, so I'm making note of it here.

Environment

Cmajor: version 1.0.2454
OS: macOS 14.4.1 (23E224)
CPU: Apple M1

Thanks for raising this. I'll investigate

There is a fix for this included in the latest release, https://github.com/cmajor-lang/cmajor/releases/tag/1.0.2462