-
Notifications
You must be signed in to change notification settings - Fork 45
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
Make ast::Name a type wrapper that checks validity #710
Labels
apollo-compiler
issues/PRs pertaining to semantic analysis & validation
Milestone
Comments
SimonSapin
added
the
apollo-compiler
issues/PRs pertaining to semantic analysis & validation
label
Oct 19, 2023
SimonSapin
added a commit
that referenced
this issue
Oct 20, 2023
SimonSapin
added a commit
that referenced
this issue
Oct 20, 2023
SimonSapin
added a commit
that referenced
this issue
Oct 20, 2023
SimonSapin
added a commit
that referenced
this issue
Nov 9, 2023
SimonSapin
added a commit
that referenced
this issue
Nov 9, 2023
SimonSapin
added a commit
that referenced
this issue
Nov 9, 2023
SimonSapin
added a commit
that referenced
this issue
Nov 10, 2023
SimonSapin
added a commit
that referenced
this issue
Nov 10, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is breaking change that we should either make before 1.0 leaves beta, or decide not to make.
In 1.0.0-beta.4
apollo_compiler::ast::Name
is a type alias forapollo_compiler::NodeStr
, a smart string type with infallible conversion from arbitrary&str
. As a result it is possible to generate invalid syntax:This simple example uses AST, but even full validation in
Schema
orExecutableDocument
would not catch this.We could change validation to find every
Name
and check its validity (must be made of oneNameStart
character followed by zero or moreNameContinue
characters) but it would be easy for validation code to miss some, and delay finding a problem until the user actually calls validation.Proposal
Instead,
ast::Name
could be changed to a wrapper type ofNodeStr
that checks validity. Conversion from&str
would be fallible. To avoid run-timeunwrap
when converting from a literal string, there could be aname!("example")
macro that checks validity at compile-time.The text was updated successfully, but these errors were encountered: