Conversation
Implements reflect.Indirect function to support pointer dereferencing. This function returns the value that a pointer points to, or returns the value unchanged if it's not a pointer. Fixes #1354 Generated with [codeagent](https://github.com/qbox/codeagent) Co-authored-by: luoliwoshang <luoliwoshang@users.noreply.github.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1355 +/- ##
=======================================
Coverage 90.18% 90.18%
=======================================
Files 43 43
Lines 12752 12752
=======================================
Hits 11501 11501
Misses 1092 1092
Partials 159 159 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
_cmptest/reflect_indirect/test.go
Outdated
There was a problem hiding this comment.
move to _demo folder & with compare test and use panic() for unexpected result @xgopilot
There was a problem hiding this comment.
✅ Task completed
I've successfully moved the test from _cmptest/reflect_indirect/ to _demo/go/reflect-indirect/ and refactored it to use panic() for validation.
Changes made:
- Created new test at
_demo/go/reflect-indirect/reflect-indirect.go - Replaced
fmt.Printlnstatements with proper assertions usingpanic() - Added validation that panics when tests fail
- Added
println("PASS")at the end to indicate success - Removed old test directory
_cmptest/reflect_indirect/
Test validation:
The refactored test now:
- Non-pointer test: Validates value is 42, panics if not
- Pointer test: Validates dereferenced value is 42, panics if not
- Nil pointer test: Validates result is invalid, panics if valid
- Prints "PASS" when all assertions succeed
Committed and pushed to branch feature/reflect-indirect.
- Moved test from _cmptest/reflect_indirect/ to _demo/go/reflect-indirect/ - Refactored to use panic() for validation instead of fmt.Println - Added proper assertions for all test cases Generated with [codeagent](https://github.com/qbox/codeagent) Co-authored-by: luoliwoshang <luoliwoshang@users.noreply.github.com>
There was a problem hiding this comment.
@xgopilot keep folder name style like other demo folder
There was a problem hiding this comment.
✅ Task completed
Renamed folder from reflect-indirect to reflectindirect to match the naming convention of other demo folders (e.g., reflectfunc, gotime, timedur).
Changes:
- Renamed:
_demo/go/reflect-indirect/→_demo/go/reflectindirect/
Committed and pushed to branch feature/reflect-indirect.
There was a problem hiding this comment.
✅ Task completed
Added struct test cases to the reflect.Indirect demo as requested.
Changes made:
- Added Test 4: Struct value test - validates that
reflect.Indirectreturns the same value when given a non-pointer struct - Added Test 5: Struct pointer test - validates that
reflect.Indirectcorrectly dereferences a pointer to a struct
Test implementation:
Both tests use a Person struct with Name and Age fields and validate using panic() for assertion failures, following the existing pattern.
Committed and pushed to branch feature/reflect-indirect.
Follow naming convention of other demo folders (reflectfunc, gotime, etc.) Generated with [codeagent](https://github.com/qbox/codeagent) Co-authored-by: luoliwoshang <luoliwoshang@users.noreply.github.com>
Generated with [codeagent](https://github.com/qbox/codeagent) Co-authored-by: luoliwoshang <luoliwoshang@users.noreply.github.com>
|
@xushiwei need review |
Summary
Implements
reflect.Indirectfunction to support pointer dereferencing in llgo's reflect package.Changes
Indirectfunction to/workspace/runtime/internal/lib/reflect/value.go_cmptest/reflect_indirect/test.goImplementation
Behavior
vis a pointer (nil or non-nil): returns the dereferenced value viav.Elem()vis not a pointer: returnsvunchangedTesting
The test covers:
Expected output:
Impact
This change unblocks usage of packages that depend on
reflect.Indirect, including:encoding/binarygo/importerFixes #1354
🤖 Generated with codeagent