Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions data/transactions/logic/assembler.go
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,10 @@ func assembleBranch(ops *OpStream, spec *OpSpec, args []string) error {
}

func assembleSubstring(ops *OpStream, spec *OpSpec, args []string) error {
asmDefault(ops, spec, args)
err := asmDefault(ops, spec, args)
if err != nil {
return err
}
// Having run asmDefault, only need to check extra constraints.
start, _ := strconv.ParseUint(args[0], 0, 64)
end, _ := strconv.ParseUint(args[1], 0, 64)
Expand Down Expand Up @@ -1010,7 +1013,7 @@ type assembleFunc func(*OpStream, *OpSpec, []string) error
// Basic assembly. Any extra bytes of opcode are encoded as byte immediates.
func asmDefault(ops *OpStream, spec *OpSpec, args []string) error {
if len(args) != spec.Details.Size-1 {
ops.errorf("%s expects %d immediate arguments", spec.Name, spec.Details.Size-1)
return ops.errorf("%s expects %d immediate arguments", spec.Name, spec.Details.Size-1)
}
ops.pending.WriteByte(spec.Opcode)
for i := 0; i < spec.Details.Size-1; i++ {
Expand Down
10 changes: 10 additions & 0 deletions data/transactions/logic/eval_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1981,6 +1981,16 @@ dup; concat // 4096

func TestSubstringFlop(t *testing.T) {
t.Parallel()
// fails in compiler
testProg(t, `byte 0xf000000000000000
substring
len`, 2, expect{2, "substring expects 2 immediate arguments"})

// fails in compiler
testProg(t, `byte 0xf000000000000000
substring 1
len`, 2, expect{2, "substring expects 2 immediate arguments"})

// fails in compiler
testProg(t, `byte 0xf000000000000000
substring 4 2
Expand Down