Skip to content

IR: Make file location fields optional at decode time #132

Description

@philipaconrad

Description

Currently, you cannot deserialize JSON-formatted Rego IR instructions (such as what you'd see in a plan.json file), unless they include file location fields (file name index, row, col).

Example:

❌ This fails:

{"type":"AssignVarStmt","stmt":{"source":{"type":"local","value":2},"target":3}}

✅ This works:

{"type":"AssignVarStmt","stmt":{"source":{"type":"local","value":2},"target":3,"file":0,"col":0,"row":0}}

This seems a bit silly, since machine-generated IR (or our own future compiler passes!) may not have a meaningful line number to attach to an instruction.

Proposed Solution

I'd like those fields to be optional, and if we have to include them all the time, let's at least have them default to 0 or something during decoding, so that our JSON-formatted IR test cases can be smaller.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions