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

dslx-fmt::off in for loop header deletes the parent proc #1735

Open
mikex-oss opened this issue Nov 20, 2024 · 1 comment
Open

dslx-fmt::off in for loop header deletes the parent proc #1735

mikex-oss opened this issue Nov 20, 2024 · 1 comment
Assignees
Labels
dslx:fmt DSLX auto-formatter dslx DSLX (domain specific language) implementation / front-end

Comments

@mikex-oss
Copy link
Collaborator

Describe the bug
I tried to disable formatting of a long for loop accumulator type annotation, due to #1685 making the loop hard to read.

It deleted my entire proc.

To Reproduce
Run the following through the formatter:

struct FooType { a: u32, b: u32 }

struct BarType { c: u32, d: u32 }

const NUM_ELEMS = u32:8;
const NUM_BLOCKS = u32:2;

proc A {
    config() {  }

    init {  }

    next(_: ()) {
        // some comment
        let _some_import_code_here = true;


        let (_foo, _bar, _baz) =
            for (i, (foo, bar, baz)): (
                // dslx-fmt::off
                u32, (FooType[NUM_ELEMS][NUM_BLOCKS], BarType[NUM_ELEMS][NUM_BLOCKS], 
                      bool[NUM_ELEMS][NUM_BLOCKS])
                ) in range(u32:0, 8) {
                // dslx-fmt::on
                
                // this is another cool comment
                (foo, bar, baz)
            }((zero!<FooType[8][2]>(), zero!<BarType[8][2]>(), all_ones!<bool[8][2]>()));

        // the end
        let _my_grand_finale_here = true;
    }
}

Output:

struct FooType { a: u32, b: u32 }

struct BarType { c: u32, d: u32 }

const NUM_ELEMS = u32:8;
const NUM_BLOCKS = u32:2;

// some comment

// dslx-fmt::off

Expected behavior
Source outside the disabled formatting section should be untouched. All the code should still be present.

@mikex-oss mikex-oss added dslx DSLX (domain specific language) implementation / front-end dslx:fmt DSLX auto-formatter labels Nov 20, 2024
@dplassgit dplassgit self-assigned this Nov 21, 2024
@dplassgit
Copy link
Collaborator

dplassgit commented Nov 21, 2024

This will no longer be allowed (and the user will be notified!)

It's still broken, but after I fix it, you should be able to write:

let (_foo, _bar, _baz) =
            for (i, (foo, bar, baz)): (
                // dslx-fmt::off
                u32, (FooType[NUM_ELEMS][NUM_BLOCKS], BarType[NUM_ELEMS][NUM_BLOCKS], 
                      bool[NUM_ELEMS][NUM_BLOCKS])
                // dslx-fmt::on
                ) in range(u32:0, 8) {
                
                // this is another cool comment
                (foo, bar, baz)
            }((zero!<FooType[8][2]>(), zero!<BarType[8][2]>(), all_ones!<bool[8][2]>()));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dslx:fmt DSLX auto-formatter dslx DSLX (domain specific language) implementation / front-end
Projects
Status: In Progress
Development

No branches or pull requests

2 participants