Skip to content

Failure to reject incorrect inputs: missing function call arguments #50

@bendrissou

Description

@bendrissou

Hi,

The parser doesn't reject incorrect function calls.

As a short example, consider the following Lua input:

var = function(...)
    (4)
end

The parser parses and labels function call (4) as a valid statement, without raising an error!

Here is the output:

{
    "Chunk": {
        "body": {
            "Block": {
                "body": [
                    {
                        "Assign": {
                            "targets": [
                                {
                                    "Name": {
                                        "id": "var",
                                        "start_char": 0,
                                        "stop_char": 2,
                                        "line": 1
                                    }
                                }
                            ],
                            "values": [
                                {
                                    "AnonymousFunction": {
                                        "args": [
                                            {
                                                "Varargs": {
                                                    "start_char": null,
                                                    "stop_char": null,
                                                    "line": null
                                                }
                                            }
                                        ],
                                        "body": {
                                            "Block": {
                                                "body": [
                                                    {
                                                        "Number": {
                                                            "n": 4,
                                                            "start_char": 25,
                                                            "stop_char": 25,
                                                            "line": 2
                                                        }
                                                    }
                                                ],
                                                "start_char": 24,
                                                "stop_char": 30,
                                                "line": 2
                                            }
                                        },
                                        "start_char": 6,
                                        "stop_char": 30,
                                        "line": 1
                                    }
                                }
                            ],
                            "start_char": 0,
                            "stop_char": 30,
                            "line": 1
                        }
                    }
                ],
                "start_char": 0,
                "stop_char": 30,
                "line": 1
            }
        },
        "start_char": 0,
        "stop_char": 30,
        "line": 1
    }
}

In comparison to the official Lua grammar, and official Lua implementation, the input is invalid. This is because a function call should be followed by one or more arguments.

So my question is : is this behaviour intended? Or is it a parsing error?

Thank you.

Activity

boolangery

boolangery commented on Oct 27, 2024

@boolangery
Owner

Fixed on master, will release a version soon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Failure to reject incorrect inputs: missing function call arguments · Issue #50 · boolangery/py-lua-parser