0xfaded / eval

BSD 3-Clause "New" or "Revised" License
34 stars 7 forks source link

[r=Rocky] Carl check typed const exprs #34

Closed 0xfaded closed 10 years ago

0xfaded commented 10 years ago

Edit: This commit is for typed op untyped operations. typed op typed are next.

This is more just a heads up this is going in. There are quite a few hacks in errors.go to get the formatting of binary expression errors correct. checkbinaryexpr.go is comparatively straight forward, it just took a while to get everything right.

But now, we have ...

go> 1 + int8(2)
Kind = Type = int8
results[0] = 3
go> true + int8(2)
cannot convert true to type int8
invalid operation: true + 2 (mismatched types bool and int8)
go> string("abc") + 10000000
cannot convert 10000000 to type string
invalid operation: "abc" + 10000000 (mismatched types string and int)
go> true 
eval error: true undefined
go> true || false
eval error: true undefined
go> 1 == 1 && 1 == 1
eval error: invalid binary operation <bool Value> && <bool Value>
go> int8(100) + 100
constant 200 overflows int8

There are still some rubbish errors being produced by bool expressions, but these are from the evaluator not the checker.

Feel free to comment or merge

rocky commented 10 years ago

In terms of the what, this is fantastic! Will be looking at over the next day in detail.

rocky commented 10 years ago

Just want to understand something. When I run rebuild _checkbinary_exprtest.go from testgen. I get lots of errors like this:

    helper_for_test.go:144: 
        0. Expected `illegal constant expression: untyped number % untyped number` != `illegal constant expression: ideal % ideal`
        Wrong check errors for expression '4 % 8.0i'

The expected error messages are the ones with the better error messages, but what seems to be coming out (with new and old code) are messages with "ideal". This is expected, right?

0xfaded commented 10 years ago

we are using different versions of go. I just grabbed whatever was in the ubuntu repo, which was 1.1.2. I rhink you must be on 1.2. Add it as an issue and ill fix it once my actual new laptop arrives, not the 5 year old dell i bought to tide me by in the mean time.

Carl 2014/01/12 16:09 "R. Bernstein" notifications@github.com:

Just want to understand something. When I run rebuild _checkbinary_exprtest.go from testgen. I get lots of errors like this:

helper_for_test.go:144:
    0. Expected `illegal constant expression: untyped number % untyped number` != `illegal constant expression: ideal % ideal`
    Wrong check errors for expression '4 % 8.0i'

The expected error message is the one with the better error messages, but what seems to be coming out (with new and old code) are messages with "ideal". This is expected, right?

— Reply to this email directly or view it on GitHubhttps://github.com/0xfaded/eval/pull/34#issuecomment-32115517 .