Skip to content

Improve faulty parsing of byte array literal (alternative version) #12818

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

Merged

Conversation

privat
Copy link
Contributor

@privat privat commented Feb 20, 2023

Parsing keeps the content of faulty elements in byte array literals by interpreting the faulty element as classic literal array elements (instead of just skipping them), and put them in an instance of RBLiteralByteArrayErrorNode instead of in a faulty RBLiteralByteArrayNode instance as previously.
The old way was fragile and broke clients (including compilation and execution), since a value of a RBLiteralByteArrayNode can only contain bytes.

Note: This is an alternative implementation of #12817 — there can be only one. that is somewhat simpler (you can compare the diffs) and more robust.
The only drawback is that RBEnglobingErrorNode (the superclass of the error node used) need love:

  • weird spaces in formatting.
  • contents should have a s (I think)
  • mandatory error is problematic when the error is in the content (so no specific error message on the whole compound)
    But I consider these to be out of the scope of the PR and should be solved independently.

@privat
Copy link
Contributor Author

privat commented Feb 20, 2023

Maybe a discussion point (that also applies to #12817 ): the choice currently (and previously) done in case of error is to consume elements until a closing bracket ]. An alternative policy could be to consider having an unfinished literal (someone forgot the ], or is still writing and did not enter it yet) then continue the parsing as if a ] was present (the node is still an error node, obviously).

@MarcusDenker
Copy link
Member

I restarted the CI run and now this looks odd: It shows an error and I can not restart it anymore. Very very odd

Copy link
Member

@guillep guillep left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

I wonder, why a lot of tests are removed, is that because they seem superfluous or it is a mistake?

@MarcusDenker
Copy link
Member

I think I did the conflict resolution wrong, the tests should have been added, not removed

@privat privat force-pushed the improve-faulty-parsing-bytearray-alt branch from 468be24 to f81ebb6 Compare February 23, 2023 12:32
@privat
Copy link
Contributor Author

privat commented Feb 23, 2023

I rebased the commits to solve the merge

Copy link
Member

@guillep guillep left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ci fails because of the syntax error I think

@privat privat force-pushed the improve-faulty-parsing-bytearray-alt branch from f81ebb6 to 5d21ae0 Compare February 23, 2023 13:50
@privat
Copy link
Contributor Author

privat commented Feb 23, 2023

oops. I shouldn't have solved the conflicts by hand in a text editor before the first coffee.

@privat
Copy link
Contributor Author

privat commented Feb 23, 2023

tests are ok (but the windows box is dead)

@MarcusDenker
Copy link
Member

I like this solution better than the alternative, as here we know that we have a wrong ByteArray

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

Successfully merging this pull request may close these issues.

3 participants