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

Invalid code generated with Java or Rust keywords as field name or ISL type name #99

Open
desaikd opened this issue Apr 10, 2024 · 0 comments
Labels
bug Something isn't working code generation Improvements for code generation subcommand `generate`

Comments

@desaikd
Copy link
Contributor

desaikd commented Apr 10, 2024

Currently, code generation can generate invalid Java or Rust code for ISL types that have names using keywords of Java/Rust programming language. This is also an issue for field names that have these keywords.

e.g.
Something like the following generates invalid rust code:

type::{
 name: bag,
 fields: closed::{
    type: {type: string, regex: "bag"},
    items: {type: shape}
 }
}

Note the field whose name is type.
This results in code like:

#[derive(Debug, Clone, Default)]
pub struct Bag {
    type: AnonymousType1,
    items: AnonymousType2,
}

For Rust, can use raw identifiers: https://doc.rust-lang.org/reference/identifiers.html#raw-identifiers
For Java, a possible solution is to add a suffix (e.g. _) for keywords used as variable/class names.

CC: @jpschorr

@desaikd desaikd added the code generation Improvements for code generation subcommand `generate` label Apr 10, 2024
@desaikd desaikd added the bug Something isn't working label Apr 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working code generation Improvements for code generation subcommand `generate`
Projects
Status: No status
Development

No branches or pull requests

1 participant