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

Panic when using unary operations on this #2416

Closed
addisoncrump opened this issue Nov 7, 2022 · 6 comments
Closed

Panic when using unary operations on this #2416

addisoncrump opened this issue Nov 7, 2022 · 6 comments
Labels
bug Something isn't working E-Medium Medium difficulty problem vm Issues and PRs related to the Boa Virtual Machine.
Milestone

Comments

@addisoncrump
Copy link
Contributor

Describe the bug
Using a unary operator on this causes boa to panic.

To Reproduce
Execute the following script:

++this;

Which causes the following error:

thread 'main' panicked at 'not yet implemented: access_set `this`', boa_engine/src/bytecompiler/mod.rs:828:29
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Expected behavior
Boa should issue a syntax error with an invalid operand.

Additional context
Discovered by #2401

@addisoncrump addisoncrump added the bug Something isn't working label Nov 7, 2022
@Razican Razican added the vm Issues and PRs related to the Boa Virtual Machine. label Nov 7, 2022
@Razican Razican added this to the v0.17.0 milestone Nov 7, 2022
@e-codes-stuff
Copy link
Contributor

This is only disallowed for specifically the unary operations which would assign to this right? I think it would be possible to add in the error by turning this code in bytecompiler/expression/unary.rs from this:

            UnaryOp::DecrementPost => {
                // TODO: promote to an early error.
                let access = Access::from_expression(unary.target()).ok_or_else(|| {
                    JsNativeError::syntax().with_message("Invalid decrement operand")
                })?;

To something like this:

            UnaryOp::DecrementPost => {
                // TODO: promote to an early error.
                let access = Access::from_expression(unary.target())
                    .filter(|a| a != Access::This)
                    .ok_or_else(|| {
                        JsNativeError::syntax().with_message("Invalid decrement operand")
                    })?;

For anyone more knowledgeable, does this seem to be correct?

@jedel1043
Copy link
Member

It is correct, but I would very much prefer if we moved the error to the parser.

@veera-sivarajan
Copy link
Contributor

Hi, can I work on this issue?

@jedel1043 jedel1043 added the E-Medium Medium difficulty problem label Dec 26, 2022
@jedel1043
Copy link
Member

@veera-sivarajan Seems like @e-codes-stuff was checking out the issue, so maybe they have some WIP fix?

@e-codes-stuff
Copy link
Contributor

e-codes-stuff commented Dec 26, 2022 via email

@addisoncrump
Copy link
Contributor Author

addisoncrump commented Jan 2, 2023

With this fixed, there are currently no bugs found by the fuzzer with implied oracles. Huzzah!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working E-Medium Medium difficulty problem vm Issues and PRs related to the Boa Virtual Machine.
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

5 participants