symphonytool / symphony

The Symphony IDE
5 stars 4 forks source link

Interpreter: Floor expression not working and return type not checked #292

Closed richardpaynea55 closed 9 years ago

richardpaynea55 commented 9 years ago

The floor expression is not returning an integer/natural number when called in a function/operation in the interpreter, and the result type is not being checked upon completion of the function/operation.

Using the model below:

channels
inputCh : nat
output : nat

functions
floorTest : nat -> nat
floorTest(n) == floor n/3

process test = 
begin
 @ inputCh?n -> output!(floorTest(n)) -> Skip 
end

The error below is returned:

Error 4065: Value 3.3333333333333335 is not a nat in '/~/Workspace/FloorBug/FloorBug.cml' at line 13:24 at in ''/~/Workspace/FloorBug/FloorBug.cml' at line 13:24

The same is true when calling the floor expression in an operation.

richardpaynea55 commented 9 years ago

The floor issue is fine - was a problem with not bracketing! Changed to floor (n/3) is fine. However, still assume that the interpreter should catch mis-typed return values before being returned to action?

lausdahl commented 9 years ago

The error comes from the function evaluation. The last thing the function does when evaluated is that it converts the actual value to the expected one. Here it throws a ValueException since they dont match. This is then thrown up and shown at the apply expression (floorTest(n)) since this was what cause it. The function is ok it is just partially defined so some values may lead to runtime errors.