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

Improve error messages #1

Open
CapsAdmin opened this issue Oct 31, 2020 · 1 comment
Open

Improve error messages #1

CapsAdmin opened this issue Oct 31, 2020 · 1 comment

Comments

@CapsAdmin
Copy link
Owner

At the moment error messages are a bit all over the place. In some cases the token nodes that the error points to is also not always correct.

I've thought about representing errors with a "because chain", not sure if this is practically useful or if it's just a neat idea. Something like this:

local A = {
    foo = true,
    bar = false,
    faz = {
        one = 1,
        two = 2,
    }
}

local B = {
    foo = true,
    bar = false,
    faz = {
        one = 1,
        two = 3,
    }
}

A is not a subset of B because
A.faz is not a subset of B.faz because
A.faz.two is not a subset of B.faz.two because
2 is not the same literal as 3

It's a bit similar to a stack trace. The problem I have with stack traces is that it's not always useful to see all of the stack, but figuring out which level to cut out is not easily solvable.

@CapsAdmin
Copy link
Owner Author

I started doing this and it feels easier to me to read than i was expecting. Especially when it's split in newlines.

At the moment, this case is obviously too verbose

_G does not contain "Token" 
because "Token" is not the same value as "__name"
"Token" is not the same value as "return_type"
"Token" is not the same value as "argument_type"
"Token" is not the same value as "exclude"
"Token" is not the same value as "Tuple"
"Token" is not the same value as "enum"
"Token" is not the same value as "error_inside_base_environment"
"Token" is not the same value as "keysof"
"Token" is not the same value as "type_assert"
"Token" is not the same value as "subset_of"
-- ETC

I'm thinking I should embrace verbosity and then simplify the message when displaying the error.

Random quick thought, maybe even use a "language" that is easily parsable that then generates the proper error in English.

"Token" not in _G:
_G["Token"] != "__name",
_G["Token"] != "__name",
_G["Token"] != "__name",
-- ETC

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