Reject Leo keywords as package names#29496
Conversation
| Program::<TestnetV0>::KEYWORDS.iter().copied().chain(restricted) | ||
| } | ||
|
|
||
| fn is_leo_keyword(name: &str) -> bool { |
There was a problem hiding this comment.
name is already validated as a single identifier above, so this could skip the full lex() + collect. Worth exposing one pub fn is_keyword(&str) -> bool in parser-rowan and routing all keyword checks through it — including the parser's symbol_is_keyword (crates/parser/src/rowan.rs), which is a hand-maintained matches! over sym::* that's already drifted from the lexer (e.g. missing view/dyn). It could be deleted in favor of the shared helper so the lexer stays the single source of truth.
| } | ||
|
|
||
| // Check reserved keywords. | ||
| if reserved_keywords().any(|kw| kw == name) { |
There was a problem hiding this comment.
Now that we also reject Leo keywords, consider renaming reserved_keywords -> aleo_reserved_keywords and adding an is_aleo_keyword(name) predicate, so the two checks read symmetrically: is_leo_keyword(name) / is_aleo_keyword(name).
7b2a1c6 to
747e6e8
Compare
Motivation
Fixes #29071.
leo newcurrently accepts package names that are Leo keywords. Those names later conflict with Leo syntax, so this rejects keyword names during package name validation.Test Plan
cargo test -p leo-package -- --nocaptureRelated PRs
None