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

Shift by a string literal is not rejected by type checker #5094

Open
vlstill opened this issue Jan 9, 2025 · 0 comments · May be fixed by #5099
Open

Shift by a string literal is not rejected by type checker #5094

vlstill opened this issue Jan 9, 2025 · 0 comments · May be fixed by #5099
Assignees
Labels
bug This behavior is unintended and should be fixed. core Topics concerning the core segments of the compiler (frontend, midend, parser)

Comments

@vlstill
Copy link
Contributor

vlstill commented Jan 9, 2025

I modified https://github.com/p4lang/p4c/blob/main/testdata/p4_16_samples/arith5-bmv2.p4:

    action shift()
    { h.h.c = (int<64>)(h.h.a >> "aaaa"); sm.egress_spec = 0; }

Note that this code does not make any sense and should be rejected by the type checker. Howerver, it is not rejected:

$ ./build/p4c/p4test p4c/testdata/p4_16_samples/arith5-bmv2.p4
# [nothing, exitcode = 0]

If the shift is replaced with addition, the check works:

p4c/testdata/p4_16_samples/arith5-bmv2.p4(30): [--Werror=type-error] error: +: cannot be applied to expression '"aaaa"' with type 'string'
    { h.h.c = (int<64>)(h.h.a + "aaaa"); sm.egress_spec = 0; }
                                     ^
@vlstill vlstill added bug This behavior is unintended and should be fixed. core Topics concerning the core segments of the compiler (frontend, midend, parser) labels Jan 9, 2025
@vlstill vlstill self-assigned this Jan 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This behavior is unintended and should be fixed. core Topics concerning the core segments of the compiler (frontend, midend, parser)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant