ion-cli
ion-cli copied to clipboard
Invalid code generated with Java or Rust keywords as field name or ISL type name
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