Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Checking for methodset existance #4126

Merged
merged 2 commits into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions interp/interpreter.go
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,10 @@ func (r *runner) run(fn *function, params []value, parentMem *memoryView, indent
if err != nil {
return nil, mem, r.errorAt(inst, err)
}
if typecodePtr.offset() == 0 {
locals[inst.localIndex] = literalValue{uint8(0)}
break
}
marco6 marked this conversation as resolved.
Show resolved Hide resolved
typecodePtrOffset, err := typecodePtr.addOffset(-int64(r.pointerSize))
if err != nil {
return nil, mem, r.errorAt(inst, err) // unlikely
Expand Down
11 changes: 11 additions & 0 deletions testdata/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,14 @@ func sliceString(s string, start, end int) string {
func sliceSlice(s []int, start, end int) []int {
return s[start:end]
}

type outside struct{}

func init() {
_, _ = any(0).(interface{ DoesNotExist() })
_, _ = any("").(interface{ DoesNotExist() })
_, _ = any(outside{}).(interface{ DoesNotExist() })

type inside struct{}
_, _ = any(inside{}).(interface{ DoesNotExist() })
}