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

When trying to disable formatting around a test function it segfaults #1760

Closed
dplassgit opened this issue Dec 3, 2024 · 1 comment
Closed
Assignees
Labels
dslx:fmt DSLX auto-formatter dslx DSLX (domain specific language) implementation / front-end

Comments

@dplassgit
Copy link
Collaborator

dplassgit commented Dec 3, 2024

To Reproduce
Try to format:

#[test]
// dslx-fmt::off
fn test() {
}
// dslx-fmt::on

Expected behavior
Output = input

Actual behavior

segfault:

F1203 08:52:26.712443    8951 logging.cc:62] assert.h assertion failed at third_party/xls/common/casts.h:59 in To xls::down_cast(From *) [To = xls::dslx::Function *, From = xls::dslx::AstNode]: f == nullptr || dynamic_cast<To>(f) != nullptr
*** Check failure stack trace: ***
...
    @     0x7ff4f146c800  xls::dslx::(anonymous namespace)::AstCloner::HandleTestFunction()
    @     0x7ff4f147a65d  xls::dslx::(anonymous namespace)::AstCloner::ReplaceOrVisit()
    @     0x7ff4f14858cb  std::__u::__variant_detail::__visitation::__base::__dispatcher<>::__dispatch<>()
    @     0x7ff4f1468b7c  xls::dslx::(anonymous namespace)::AstCloner::HandleModule()
    @     0x7ff4f1465b92  xls::dslx::CloneModule()
    @     0x7ff55f70fbc5  xls::dslx::AutoFmt()
    @     0x7ff55fb861cf  xls::dslx::(anonymous namespace)::ModuleFmtTest::DoFmt()
...
@dplassgit dplassgit added dslx DSLX (domain specific language) implementation / front-end dslx:fmt DSLX auto-formatter labels Dec 3, 2024
@dplassgit dplassgit self-assigned this Dec 3, 2024
@dplassgit dplassgit changed the title When trying to disable formatting around a test function it removes the function When trying to disable formatting around a test function it segfaults Dec 3, 2024
@dplassgit dplassgit moved this to In Progress in XLS usability Dec 16, 2024
@dplassgit
Copy link
Collaborator Author

This is partially because it can't find the comment between the #[test] and the function, and partially because the NameDef isn't castable to a VerbatimNode. We'll disallow format disabling in this situation.

copybara-service bot pushed a commit that referenced this issue Dec 17, 2024
…and return an error from the ast_cloner. Since `struct` fields aren't AST nodes yet, it's currently infeasible to disable formatting in `struct`s.

Similar for certain ways of disabling formatting in and around functions.

#1756

#1760

PiperOrigin-RevId: 707104604
@dplassgit dplassgit moved this from In Progress to Done in XLS usability Dec 17, 2024
@dplassgit dplassgit closed this as completed by moving to Done in XLS usability Dec 17, 2024
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: Done
Development

No branches or pull requests

1 participant