diff options
author | Marco Manino <[email protected]> | 2024-03-18 08:32:17 +0100 |
---|---|---|
committer | Ayke <[email protected]> | 2024-05-13 16:49:18 +0200 |
commit | 71878c2c0c3ed83aa332b32afa9fbef16de2bccc (patch) | |
tree | 0796853078bbb6746fa6c880d6649ccceded0949 | |
parent | cef2a82c97eeef34fffe72b4cbc60239114dec26 (diff) | |
download | tinygo-71878c2c0c3ed83aa332b32afa9fbef16de2bccc.tar.gz tinygo-71878c2c0c3ed83aa332b32afa9fbef16de2bccc.zip |
Adding a comment
-rw-r--r-- | interp/interpreter.go | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/interp/interpreter.go b/interp/interpreter.go index e0074ba26..ea5eeaa12 100644 --- a/interp/interpreter.go +++ b/interp/interpreter.go @@ -427,13 +427,20 @@ func (r *runner) run(fn *function, params []value, parentMem *memoryView, indent if err != nil { return nil, mem, r.errorAt(inst, err) } + // typecodePtr always point to the numMethod field in the type + // description struct. The methodSet, when present, comes right + // before the numMethod field (the compiler doesn't generate + // method sets for concrete types without methods). + // Considering that the compiler doesn't emit interface type + // asserts for interfaces with no methods (as the always succeed) + // then if the offset is zero, this assert must always fail. if typecodePtr.offset() == 0 { locals[inst.localIndex] = literalValue{uint8(0)} break } typecodePtrOffset, err := typecodePtr.addOffset(-int64(r.pointerSize)) if err != nil { - return nil, mem, r.errorAt(inst, err) // unlikely + return nil, mem, r.errorAt(inst, err) } methodSetPtr, err := mem.load(typecodePtrOffset, r.pointerSize).asPointer(r) if err != nil { |