Skip to content

check struct field name is a string in Fetch and get#973

Open
netliomax25-code wants to merge 1 commit into
expr-lang:masterfrom
netliomax25-code:struct-key-string-check
Open

check struct field name is a string in Fetch and get#973
netliomax25-code wants to merge 1 commit into
expr-lang:masterfrom
netliomax25-code:struct-key-string-check

Conversation

@netliomax25-code
Copy link
Copy Markdown

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant