Skip to content

interp can't handle regexp.MustCompile because it gives up on panic() #4848

Open
@dkegel-fastly

Description

@dkegel-fastly

interp very sensibly avoids evaluating init functions with side effects.
panic() has the side effect of halting the program.
This means that regexp.MustCompile() is always executed purely at runtime instead of compiletime... leading to slow startup for edge applications, where init runs for every request.

Thinking it through, though, it would be completely reasonable for panic()
inside an init function to halt compilation. It would give a better
developer experience - invalid regexps in init functions would halt
compilation! - and a better runtime experience, particularly on the edge.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions