Skip to content

Commit 71878c2

Browse files
marco6aykevl
authored andcommitted
Adding a comment
1 parent cef2a82 commit 71878c2

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

interp/interpreter.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,13 +427,20 @@ func (r *runner) run(fn *function, params []value, parentMem *memoryView, indent
427427
if err != nil {
428428
return nil, mem, r.errorAt(inst, err)
429429
}
430+
// typecodePtr always point to the numMethod field in the type
431+
// description struct. The methodSet, when present, comes right
432+
// before the numMethod field (the compiler doesn't generate
433+
// method sets for concrete types without methods).
434+
// Considering that the compiler doesn't emit interface type
435+
// asserts for interfaces with no methods (as the always succeed)
436+
// then if the offset is zero, this assert must always fail.
430437
if typecodePtr.offset() == 0 {
431438
locals[inst.localIndex] = literalValue{uint8(0)}
432439
break
433440
}
434441
typecodePtrOffset, err := typecodePtr.addOffset(-int64(r.pointerSize))
435442
if err != nil {
436-
return nil, mem, r.errorAt(inst, err) // unlikely
443+
return nil, mem, r.errorAt(inst, err)
437444
}
438445
methodSetPtr, err := mem.load(typecodePtrOffset, r.pointerSize).asPointer(r)
439446
if err != nil {

0 commit comments

Comments
 (0)