Repository navigation
check struct field name is a string in Fetch and get - #973
netliomax25-code wants to merge 1 commit into
Conversation
|
any update? |
sanmaxdev
left a comment
There was a problem hiding this comment.
The struct-key guard is consistent across get and runtime field access, and both paths have regression coverage.
Passed:
go test ./...git diff origin/master...HEAD --check
|
Lines up with what I see locally. Reran the full suite on the current head and it's green, including The branch is two commits behind master but still merges cleanly. I can rebase it if a maintainer wants it current before merging. |
|
Will take a look. I need to run local benches. |
7b5406e to
0e9129d
Compare
|
Rebased onto master first so the numbers are against current code: #952 rewrote the struct branch of On the benches, my first pass was useless at ±35% run to run, so I built master and patch test binaries up front and interleaved them A/B, 14 rounds each (Apple M4, go1.25.5): B/op and allocs/op are byte-identical on all five. A micro-bench calling Benchmark noise isn't great evidence either way, so the deterministic version: Two other notes:
Worth mentioning in case it saves you a step: no checks have ever reported on this branch, so the |
runtime.Fetch (runtime.go:76) and the get builtin (lib.go:598) read a struct field name with an unchecked i.(string), so indexing a struct held in an any value with a non-string key panics with a raw interface conversion. Use a checked assertion so Fetch falls through to its usual "cannot fetch" error and get returns nil per its no-panic contract.