diff --git a/pkg/corset/parser.go b/pkg/corset/parser.go index 80f9e63..9944c92 100644 --- a/pkg/corset/parser.go +++ b/pkg/corset/parser.go @@ -379,8 +379,22 @@ func (p *Parser) parseColumnDeclarationAttributes(attrs []sexp.SExp) (Type, bool } // switch symbol.Value { - case ":display", ":opcode": + case ":display": // skip these for now, as they are only relevant to the inspector. + if i+1 == len(attrs) { + return nil, false, p.translator.SyntaxError(ith, "incomplete display definition") + } else if attrs[i+1].AsSymbol() == nil { + return nil, false, p.translator.SyntaxError(ith, "malformed display definition") + } + // Check what display attribute we have + switch attrs[i+1].AsSymbol().String(false) { + case ":dec", ":hex", ":bytes", ":opcode": + // all good + i = i + 1 + default: + // not good + return nil, false, p.translator.SyntaxError(ith, "unknown display definition") + } case ":array": if array, err = p.parseArrayDimension(attrs[i+1]); err != nil { return nil, false, err diff --git a/pkg/test/invalid_corset_test.go b/pkg/test/invalid_corset_test.go index bc94688..b5f3de7 100644 --- a/pkg/test/invalid_corset_test.go +++ b/pkg/test/invalid_corset_test.go @@ -283,6 +283,30 @@ func Test_Invalid_Type_08(t *testing.T) { CheckInvalid(t, "type_invalid_08") } +func Test_Invalid_Type_09(t *testing.T) { + CheckInvalid(t, "type_invalid_09") +} + +func Test_Invalid_Type_10(t *testing.T) { + CheckInvalid(t, "type_invalid_10") +} + +func Test_Invalid_Type_11(t *testing.T) { + CheckInvalid(t, "type_invalid_11") +} + +func Test_Invalid_Type_12(t *testing.T) { + CheckInvalid(t, "type_invalid_12") +} + +func Test_Invalid_Type_13(t *testing.T) { + CheckInvalid(t, "type_invalid_13") +} + +func Test_Invalid_Type_14(t *testing.T) { + CheckInvalid(t, "type_invalid_14") +} + // =================================================================== // Range Constraints // =================================================================== diff --git a/pkg/test/valid_corset_test.go b/pkg/test/valid_corset_test.go index f24d494..adcf72a 100644 --- a/pkg/test/valid_corset_test.go +++ b/pkg/test/valid_corset_test.go @@ -408,6 +408,14 @@ func Test_Type_08(t *testing.T) { Check(t, false, "type_08") } +func Test_Type_09(t *testing.T) { + Check(t, false, "type_09") +} + +func Test_Type_10(t *testing.T) { + Check(t, false, "type_10") +} + // =================================================================== // Range Constraints // =================================================================== @@ -794,11 +802,10 @@ func TestSlow_Euc(t *testing.T) { Check(t, true, "euc") } -/* - func TestSlow_Oob(t *testing.T) { - Check(t, true, "oob") - } -*/ +func TestSlow_Oob(t *testing.T) { + Check(t, true, "oob") +} + func TestSlow_Stp(t *testing.T) { Check(t, true, "stp") } diff --git a/testdata/oob.lisp b/testdata/oob.lisp index 0ec0b74..a839679 100644 --- a/testdata/oob.lisp +++ b/testdata/oob.lisp @@ -36,6 +36,45 @@ (OUTGOING_DATA :i128 :array [4]) (OUTGOING_RES_LO :i128)) +(defconst + ;; Stop and Arithmetic Operations + EVM_INST_ADD 0x01 + EVM_INST_DIV 0x04 + EVM_INST_MOD 0x06 + ;; Comparison & Bitwise Logic Operations + EVM_INST_LT 0x10 + EVM_INST_GT 0x11 + EVM_INST_EQ 0x14 + EVM_INST_ISZERO 0x15 + ;; + MAX_CODE_SIZE 24576 + EIP2681_MAX_NONCE 18446744073709551615 ;; = 2^64 - 1 + ;; + GAS_CONST_G_CALL_STIPEND 2300 + ;; + OOB_INST_JUMP 0x56 + OOB_INST_JUMPI 0x57 + OOB_INST_RDC 0x3E + OOB_INST_CDL 0x35 + OOB_INST_XCALL 0xCC + OOB_INST_CALL 0xCA + OOB_INST_CREATE 0xCE + OOB_INST_SSTORE 0x55 + OOB_INST_DEPLOYMENT 0xF3 + OOB_INST_ECRECOVER 0xFF01 + OOB_INST_SHA2 0xFF02 + OOB_INST_RIPEMD 0xFF03 + OOB_INST_IDENTITY 0xFF04 + OOB_INST_ECADD 0xFF06 + OOB_INST_ECMUL 0xFF07 + OOB_INST_ECPAIRING 0xFF08 + OOB_INST_BLAKE_CDS 0xFA09 + OOB_INST_BLAKE_PARAMS 0xFB09 + OOB_INST_MODEXP_CDS 0xFA05 + OOB_INST_MODEXP_XBS 0xFB05 + OOB_INST_MODEXP_LEAD 0xFC05 + OOB_INST_MODEXP_PRICING 0xFD05 + OOB_INST_MODEXP_EXTRACT 0xFE05) (module oob) diff --git a/testdata/type_09.accepts b/testdata/type_09.accepts index aa9e59f..51fab06 100644 --- a/testdata/type_09.accepts +++ b/testdata/type_09.accepts @@ -24,4 +24,4 @@ { "BIT": [0,1], "X": [1,0] } { "BIT": [0,1], "X": [2,0] } ;; -{ "BIT": [1,1], "X": [1,1] } +{ "BIT": [1,1], "X": [0,0] } diff --git a/testdata/type_09.lisp b/testdata/type_09.lisp index da202f4..9db0b6a 100644 --- a/testdata/type_09.lisp +++ b/testdata/type_09.lisp @@ -1,2 +1,2 @@ -(defcolumns (X :i1@bool@prove) (Y :i4@loob)) -(defconstraint c1 () (if X Y)) +(defcolumns (BIT :i1@bool@prove) (X :i4@loob)) +(defconstraint c1 () (if BIT X)) diff --git a/testdata/type_10.accepts b/testdata/type_10.accepts new file mode 100644 index 0000000..3fde5de --- /dev/null +++ b/testdata/type_10.accepts @@ -0,0 +1,6 @@ +{ "A": [], "B": [], "C": [], "D": [] } +{ "A": [0], "B": [0], "C": [0], "D": [0] } +{ "A": [1], "B": [0], "C": [0], "D": [0] } +{ "A": [0], "B": [1], "C": [0], "D": [0] } +{ "A": [0], "B": [0], "C": [1], "D": [0] } +{ "A": [0], "B": [0], "C": [0], "D": [1] } diff --git a/testdata/type_10.lisp b/testdata/type_10.lisp new file mode 100644 index 0000000..c78d217 --- /dev/null +++ b/testdata/type_10.lisp @@ -0,0 +1,5 @@ +(defcolumns + (A :display :dec) + (B :display :hex) + (C :display :bytes) + (D :display :opcode)) diff --git a/testdata/type_invalid_09.lisp b/testdata/type_invalid_09.lisp index 68e5d41..04c1c03 100644 --- a/testdata/type_invalid_09.lisp +++ b/testdata/type_invalid_09.lisp @@ -1,4 +1,4 @@ -;;error:2:1-2:blah +;;error:6:26-27:invalid condition (neither loobean nor boolean) (defcolumns (X :i1) (Y :i1) (A :i4@loob) (B :i4@loob)) (definterleaved Z (X Y)) (definterleaved C (A B)) diff --git a/testdata/type_invalid_10.lisp b/testdata/type_invalid_10.lisp index 688e509..95126f4 100644 --- a/testdata/type_invalid_10.lisp +++ b/testdata/type_invalid_10.lisp @@ -1,4 +1,4 @@ -;;error:2:1-2:blah +;;error:6:26-27:invalid condition (neither loobean nor boolean) (defcolumns (X :i1@loob) (Y :i1) (A :i4@loob) (B :i4@loob)) (definterleaved Z (X Y)) (definterleaved C (A B)) diff --git a/testdata/type_invalid_11.lisp b/testdata/type_invalid_11.lisp index 0045b57..d39bea5 100644 --- a/testdata/type_invalid_11.lisp +++ b/testdata/type_invalid_11.lisp @@ -1,4 +1,4 @@ -;;error:2:1-2:blah +;;error:6:26-27:invalid condition (neither loobean nor boolean) (defcolumns (X :i1) (Y :i1@loob) (A :i4@loob) (B :i4@loob)) (definterleaved Z (X Y)) (definterleaved C (A B)) diff --git a/testdata/type_invalid_12.lisp b/testdata/type_invalid_12.lisp index 1fa5e1c..ecebd09 100644 --- a/testdata/type_invalid_12.lisp +++ b/testdata/type_invalid_12.lisp @@ -1,4 +1,4 @@ -;;error:2:1-2:blah +;;error:6:26-27:invalid condition (neither loobean nor boolean) (defcolumns (X :i1@bool) (Y :i1) (A :i4@loob) (B :i4@loob)) (definterleaved Z (X Y)) (definterleaved C (A B)) diff --git a/testdata/type_invalid_13.lisp b/testdata/type_invalid_13.lisp index 7cd1415..0f2c87d 100644 --- a/testdata/type_invalid_13.lisp +++ b/testdata/type_invalid_13.lisp @@ -1,4 +1,4 @@ -;;error:2:1-2:blah +;;error:6:26-27:invalid condition (neither loobean nor boolean) (defcolumns (X :i1) (Y :i1@bool) (A :i4@loob) (B :i4@loob)) (definterleaved Z (X Y)) (definterleaved C (A B)) diff --git a/testdata/type_invalid_14.lisp b/testdata/type_invalid_14.lisp new file mode 100644 index 0000000..e9bc0dd --- /dev/null +++ b/testdata/type_invalid_14.lisp @@ -0,0 +1,4 @@ +;;error:3:16-24:incomplete display definition +;;error:4:16-24:unknown display definition +(defcolumns (X :display)) +(defcolumns (Y :display :int))