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

require parentheses with shifting and arithmetic #14038

Open
andrewrk opened this issue Dec 22, 2022 · 0 comments
Open

require parentheses with shifting and arithmetic #14038

andrewrk opened this issue Dec 22, 2022 · 0 comments
Labels
enhancement Solving this issue will likely involve adding new logic or components to the codebase. frontend Tokenization, parsing, AstGen, Sema, and Liveness.
Milestone

Comments

@andrewrk
Copy link
Member

This is a sub-task of #114.

const std = @import("std");

pub const max_ciphertext_len = 1 << 14 + 256;

test "operator precedence" {
    try std.testing.expect(max_ciphertext_len == 16640);
}

Actual behavior:

$ stage3/bin/zig test test.zig 
Test [1/1] test.operator precedence... FAIL (TestUnexpectedResult)
/home/andy/dev/zig/lib/std/testing.zig:509:14: 0x20bed7 in expect (test)
    if (!ok) return error.TestUnexpectedResult;
             ^
/home/andy/dev/zig/build-release/test.zig:6:5: 0x20bff5 in test.operator precedence (test)
    try std.testing.expect(max_ciphertext_len == 16640);
    ^
0 passed; 0 skipped; 1 failed.

Expected behavior:

test.zig:3:39: error: parentheses required to disambiguate operator precedence
pub const max_ciphertext_len: u16 = 1 << 14 + 256;
                                    ~~^~~~~~~~~~~
@andrewrk andrewrk added enhancement Solving this issue will likely involve adding new logic or components to the codebase. frontend Tokenization, parsing, AstGen, Sema, and Liveness. labels Dec 22, 2022
@andrewrk andrewrk added this to the 0.11.0 milestone Dec 22, 2022
@andrewrk andrewrk changed the title require parethesis with shifting and arithmetic require paretheses with shifting and arithmetic Dec 22, 2022
@andrewrk andrewrk changed the title require paretheses with shifting and arithmetic require parentheses with shifting and arithmetic Dec 22, 2022
@andrewrk andrewrk modified the milestones: 0.11.0, 0.12.0 Jun 19, 2023
@andrewrk andrewrk modified the milestones: 0.14.0, 0.15.0 Feb 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Solving this issue will likely involve adding new logic or components to the codebase. frontend Tokenization, parsing, AstGen, Sema, and Liveness.
Projects
None yet
Development

No branches or pull requests

1 participant