fix(conf): deref pointer-to-map environment instead of panicking - #987
Open
jaideeppyne wants to merge 1 commit into
Open
fix(conf): deref pointer-to-map environment instead of panicking#987jaideeppyne wants to merge 1 commit into
jaideeppyne wants to merge 1 commit into
Conversation
EnvWithCache selected the map branch using the dereferenced value's
kind, but then read the map length and keys from the original (pointer)
value. Passing a *map as the env therefore panicked with:
reflect: call of reflect.Value.Len on ptr to non-array Value
Iterate the dereferenced value in the map branch so a pointer-to-map env
is treated exactly like the map it points to (same strict mode and
element types), matching the existing behaviour for pointer-to-struct
environments.
Fixes expr-lang#825
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: jaideeppyne <jaideeppyne1997@gmail.com>
sanmaxdev
reviewed
Aug 21, 2026
sanmaxdev
left a comment
There was a problem hiding this comment.
The implementation and focused regression tests pass. Before this lands, please reconcile the behavior with #825: the issue is labeled wontfix, and the maintainer's direction was to reject *map input with an error. This patch instead supports non-nil pointers while nil pointers still panic as an unknown type. A decision on support versus rejection seems needed, along with a nil-pointer test for the chosen contract.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #825
Passing a pointer to a map as the environment panicked at compile time:
EnvWithCacheselects the map branch using the dereferenced value's kind, but then read the length and keys from the original pointer value. This iterates the dereferenced value in the map branch, so a*mapenv is treated exactly like the map it points to — same strict mode and element types — matching the existing behaviour for pointer-to-struct environments.Added a regression test under
test/issues/825/covering compile+run, strict unknown-name rejection, and element-type inference through the pointer. It panics onmasterand passes with this change.gofmt,go vet, and the full suite are green.