Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
bendrissou opened this issue Sep 26, 2023 · 0 comments
Open

Comments

@bendrissou
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant