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 compiling AirScript #340

Closed
pgrinaway opened this issue Jul 20, 2023 · 3 comments
Closed

Panic when compiling AirScript #340

pgrinaway opened this issue Jul 20, 2023 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@pgrinaway
Copy link

Hi all,

I was trying to compile some AirScript today, and after narrowing things down a little, I think there may be a bug. I tried the following AirScript example:
fail_example.txt

and get this:

============================================================
Transpiling...
thread 'main' panicked at 'internal error: entered unreachable code: unexpected constraint node: Binary(
    BinaryExpr {
        op: Mul,
        lhs: SymbolAccess(
            SymbolAccess {
                name: Local(
                    Identifier(
                        "sign_bit",
                    ),
                ),
                access_type: Default,
                offset: 0,
                ty: Some(
                    Felt,
                ),
            },
        ),
        rhs: Const(
            2048,
        ),
    },
)', parser/src/transforms/inlining.rs:535:24

On the other hand, if I move the invocation of the evaluator out of a match into its own enf, it seems to compile ok:
success_example.txt

Am I combining the match/evaluator statements incorrectly? Or might this be a bug? Thanks, and let me know if there's any other info I can provide!

@bobbinth
Copy link
Contributor

This looks like a bug. Seems like something is going wrong when we try to combine this specific evaluator with the selector from the enf match statement.

Thank you for flagging this! We'll investigate.

@bitwalker bitwalker self-assigned this Jul 21, 2023
@bitwalker bitwalker added the bug Something isn't working label Jul 21, 2023
bitwalker added a commit that referenced this issue Jul 21, 2023
This fixes an issue which caused expansion of a folded comprehension
within the context of a constraint to be improperly treated as a
constraint comprehension. This expansion occurs during the inlining
phase.

This bug occurred because a flag determines whether a given
comprehension is a constraint comprehension or a regular list
comprehension, and is set to true when expanding a constraint.
However, while expanding a constraint, we may encounter a call to a
function, such as one of the list folding builtins, in which case
a comprehension passed as an argument to those builtins is not
expressing a constraint, so the flag should be false while expanding
it.

We already manage this flag correctly in other contexts, but this one
was missed during development.

Fixes #340
@bitwalker
Copy link
Contributor

This is fixed in #341

bitwalker added a commit that referenced this issue Jul 23, 2023
This fixes an issue which caused expansion of a folded comprehension
within the context of a constraint to be improperly treated as a
constraint comprehension. This expansion occurs during the inlining
phase.

This bug occurred because a flag determines whether a given
comprehension is a constraint comprehension or a regular list
comprehension, and is set to true when expanding a constraint.
However, while expanding a constraint, we may encounter a call to a
function, such as one of the list folding builtins, in which case
a comprehension passed as an argument to those builtins is not
expressing a constraint, so the flag should be false while expanding
it.

We already manage this flag correctly in other contexts, but this one
was missed during development.

Fixes #340
@bobbinth
Copy link
Contributor

Closing this as fixes as #341 seems to have addressed this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants