Skip to content

Incorrect parsing of array subscripts #217

@davidchisnall

Description

@davidchisnall

Using this rego module, patched to import rego.v1 instead of future.keywords.every (which seems to be failing since the last rego-cpp update), we see this error:

Invalid reference bracket expression
-- ../../network_stack.rego:44:40
		"connection_type":  connection_types[connectionType],
                                       ~~~~~~~~~~~~~~

-- 
wellformed_error
~~~~~~~~~~~~~~~~

Pass expr_to_opblock failed with 1 error!

Storing the array index expression in a temporary seems to fix it:

@@ -38,9 +38,12 @@ decode_connection_capability(connection) = decoded {
        host = string_from_hex_string(connection.contents, 8)
        count(host)+1 == hostLength
 
+       some connectionTypeName
+       connectionTypeName = connection_types[connectionType]
+
        decoded = {
                "port": port,
-               "connection_type":  connection_types[connectionType],
+               "connection_type":  connectionTypeName,
                "host": host
        }
 }

So it appears to be a parsing error. This was working in pre 1.0 versions. We're currently on 1.0.1, but moving to 1.4.1 does not fix the issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions