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

Cannot disable formatting around a field #1756

Open
dplassgit opened this issue Dec 2, 2024 · 2 comments
Open

Cannot disable formatting around a field #1756

dplassgit opened this issue Dec 2, 2024 · 2 comments
Labels
dslx:fmt DSLX auto-formatter dslx DSLX (domain specific language) implementation / front-end

Comments

@dplassgit
Copy link
Collaborator

Describe the bug
If you try to disable formatting around a "type" the formatter crashes.

To Reproduce
Steps to reproduce the behavior:
Try to format this:

struct Point {
    // dslx-fmt::off
    x: u32,    
    // dslx-fmt::on
    y: u32,
}

It segfaults:

F1202 08:05:30.335632    4899 logging.cc:62] assert.h assertion failed at third_party/xls/common/casts.h:59 in To xls::down_cast(From *) [To = xls::dslx::TypeAnnotation *, From = xls::dslx::AstNode]: f == nullptr || dynamic_cast<To>(f) != nullptr
*** Check failure stack trace: ***
    @     0x7f84ca3cd399  absl::log_internal::LogMessage::SendToLog()
    @     0x7f84ca3cc8ae  absl::log_internal::LogMessage::Flush()
    @     0x7f84ca3cda19  absl::log_internal::LogMessageFatal::~LogMessageFatal()
    @     0x7f84db999574  __assert_fail
    @     0x7f8503270f63  xls::dslx::(anonymous namespace)::AstCloner::HandleStructDef()

Basically it's because VerbatimNode doesn't implement TypeAnnotation.

Expected behavior
Output = input

@dplassgit dplassgit added dslx DSLX (domain specific language) implementation / front-end dslx:fmt DSLX auto-formatter labels Dec 2, 2024
@dplassgit dplassgit moved this to Todo in XLS usability Dec 2, 2024
@dplassgit
Copy link
Collaborator Author

This happens in other places too, e.g. in function parameters.

@dplassgit
Copy link
Collaborator Author

Seems like StructMembers aren't AST nodes so we can't completely replace them with VerbatimNodes.

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: Todo
Development

No branches or pull requests

1 participant