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

No line number generated when an error occurs in isAfter #622

Closed
adrianffletcher opened this issue Jun 20, 2019 · 3 comments
Closed

No line number generated when an error occurs in isAfter #622

adrianffletcher opened this issue Jun 20, 2019 · 3 comments
Assignees
Labels
Type: Feature Request 🛍️ New feature or request

Comments

@adrianffletcher
Copy link

The following Ergo code results

  clause generateIsAfterError(request : TestRequest) : MyResponse {
    let a : DateTime? = some(now());
    let b : DateTime = now();
    enforce isAfter(a,b) else
      throw ErgoErrorResponse{ message : "Time is going backwards!" };
    return MyResponse{ output: "Test Complete" }
  }

Results in this error message:

Adrians-MBP:helloconcept adrianfletcher$ cicero execute
7:47:27 PM - info: Using current directory as template folder
7:47:27 PM - info: Loading a default sample.txt file.
7:47:27 PM - info: Loading a default request.json file.
7:47:28 PM - error: Type error. This operator received unexpected arguments of type `DateTime?'  and `DateTime'.

It would be great to get the line number that the error occurred at.
helloconcept@0.1.1.zip

@jeromesimeon
Copy link
Member

Thanks for the report. This is most likely not specific to isAfter but a not-so-great error message for operators called from within the standard library.

@jeromesimeon jeromesimeon added the Type: Feature Request 🛍️ New feature or request label Jun 20, 2019
@jeromesimeon jeromesimeon self-assigned this Jun 20, 2019
@jeromesimeon
Copy link
Member

The table used to find built-in operators (which isAfter is one of) was using dummy locations:

let prov := dummy_provenance in

An on-going fix looks promising:

bash-3.2$ ~/git/cicero/packages/cicero-cli/index.js parse 
16:07:28 - info: Using current directory as template folder
16:07:28 - info: Loading a default sample.txt file.
16:07:36 - error: Type error (at file lib/logic.ergo line 36 col 12). This operator received unexpected arguments of type `DateTime?'  and `DateTime'.
    enforce isAfter(a,b) else
            ^^^^^^^^^^^^     

@jeromesimeon
Copy link
Member

Fixed in #624

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Type: Feature Request 🛍️ New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants