Skip to content
This repository has been archived by the owner on Sep 7, 2023. It is now read-only.

Improved error reporting for missing fields #629

Closed
adrianffletcher opened this issue Jun 28, 2019 · 1 comment
Closed

Improved error reporting for missing fields #629

adrianffletcher opened this issue Jun 28, 2019 · 1 comment

Comments

@adrianffletcher
Copy link

It would be great if the ergo error produced for a reference to a non-existent field was clearer.

Currently if I run the following code:

ergo$ return { name: "Bob"}.firstName

I get the following error:

Type error (at line 1 col 7). This operator received an unexpected argument of type `{name: String}'.
return { name: "Bob"}.firstname
       ^^^^^^^^^^^^^^^^^^^^^^^^

I would like to get something like:

Type error (at line 1 col 7). Field 'firstname' does not exist for type `{name: String}'.
return { name: "Bob"}.firstname
       ^^^^^^^^^^^^^^^^^^^^^^^^
@jeromesimeon
Copy link
Member

Addressed in PR #630

$ ./bin/ergotop
Welcome to ERGOTOP version 0.8.5
ergo$ define concept Foo{ a : Integer }
ergo$ define concept Bar extends Foo{ b : String }
ergo$ return {a : 1, b: "meh" }.b
Response. "meh" : String
ergo$ return Foo{a : 1, b: "meh" }.b
Type error (at line 1 col 7). Unknown field `b' in type `Foo'
return Foo{a : 1, b: "meh" }.b
       ^^^^^^^^^^^^^^^^^^^^^  
ergo$ return Bar{a : 1, b: "meh" }.b
Response. "meh" : String
ergo$ return {a : 1, b: "meh" }.b
Response. "meh" : String
ergo$ return {a : 1, b: "meh" }.c
Type error (at line 1 col 7). The field c does not exist in type `{a: Integer, b: String}'
return {a : 1, b: "meh" }.c
       ^^^^^^^^^^^^^^^^^^^^
ergo$ return Bar{a : 1, b: "meh" }.c
Type error (at line 1 col 7). The field c does not exist in type `Bar'
return Bar{a : 1, b: "meh" }.c
       ^^^^^^^^^^^^^^^^^^^^^^^

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants