edgedb icon indicating copy to clipboard operation
edgedb copied to clipboard

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

Open dnwpark opened this issue 1 year ago • 2 comments

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 avatar May 14 '24 22:05 dnwpark

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?

msullivan avatar May 16 '24 03:05 msullivan

@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.

dnwpark avatar May 17 '24 15:05 dnwpark

That sounds reasonable

msullivan avatar May 22 '24 00:05 msullivan

@msullivan take a look when you can

dnwpark avatar May 24 '24 22:05 dnwpark