Skip to content

Sanitize Behavior of exit Command doesn't work if there is no init callback #485

@mkruselj

Description

@mkruselj
on note
    play_note(EVENT_NOTE + 12, EVENT_VELOCITY, 0, -1)
end on

function x()
    exit
end function

on note
    change_tune(EVENT_ID, -120000, 0)
    call x()
end on

Try to compile this code with the aforementioned compiler option enabled. It won't work, because this compiler option requires declaration of sksp_dummy variable, which is done in the preprocessor. Since it is done like that, it traverses the code line by line, looks for ICB by searching for on init, and then inserts declaration of that variable.

Which means this option would require two passes through the whole source code, once to detect if ICB exists (and if not, create it), once to process all exit statements. This seems inefficient, so it would be good to consider moving the implementation of this compiler option to the AST.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions