ChildsplayOSU / bogl

Haskell implementation of the BoGL language
https://bogl.engr.oregonstate.edu
BSD 3-Clause "New" or "Revised" License
7 stars 1 forks source link

Input Expressions need Verification #149

Closed montymxb closed 3 years ago

montymxb commented 4 years ago

The contents in the input buffer associated with input do not currently undergo verification before use. This results in issues with programs like so:

game Test
type Input = Int

And REPL input of:

> let x = input in x
> ...user gives 'True'
> True

Pointed out by @alexgrejuc , the above should instead report an error describing the expected and the actual type, and how they do not match (2 examples below pulled from Alex's comment on issue 25 of the frontend):

> input
You are in input mode. Enter an expression of type <type of Input>
> <ill-typed expression>
You entered an expression of type <type>. Enter an expression of type <type of Input>
> <well-typed expression>
<value of the expression>

for a type of Int would be:

input
You are in input mode. Enter an expression of type Int
>sdfsdf
You entered an expression of type Error. Enter an expression of type Int
> True
You entered an expression of type Bool. Enter an expression of type Int

In addition from issue #24 on the frontend:

What should happen is that it (the input expression) should be parsed, type checked, evaluated, and then put the result in the input buffer if the type is correct. This may require some changes on the back end and in that case I can try to help.

In summary:

montymxb commented 3 years ago

Closed by #165