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

Check if type exists when tracing type cast, is, and introspect. #7351

Merged
merged 2 commits into from
May 29, 2024

Conversation

dnwpark
Copy link
Contributor

@dnwpark dnwpark commented May 14, 2024

Given the schema:

  type MyType {
    parent: MyType;
    is_initial := .parent is null;
  }

A nicer error is produced:

error: type 'default::null' does not exist
  │
6 │     is_initial := .parent is null;
  │                              ^^^^ Did you mean to use `exists`?

close #7256

@dnwpark dnwpark force-pushed the trace-typename branch 4 times, most recently from 34b4222 to 90fc10c Compare May 15, 2024 18:16
@dnwpark dnwpark marked this pull request as ready for review May 15, 2024 18:16
@msullivan
Copy link
Member

We might want some more details in the message? Or maybe just use the span of the whole IS when it is none or null?

@dnwpark
Copy link
Contributor Author

dnwpark commented May 17, 2024

@msullivan After thinking a bit, I think that changing the span could be confusing for particularly long expressions. What do you think of changing the hint to Did you mean to use exists to check if a set is empty?

Another thing to consider is that the right side of is can also be a type expression (eg. is_initial := .parent is MyType | null;). I think it's ok to not add the hint here.

@msullivan
Copy link
Member

That sounds reasonable

@dnwpark
Copy link
Contributor Author

dnwpark commented May 24, 2024

@msullivan take a look when you can

@dnwpark dnwpark merged commit d8c6287 into master May 29, 2024
24 checks passed
@dnwpark dnwpark deleted the trace-typename branch May 29, 2024 15:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

UnresolvedReferenceError: reference to an undefined item default::null in default::MyType@is_initial_revision
2 participants