Repository navigation
compiler, reflect: expose function signature information - #6217
Conversation
6a4337e to
66e4245
Compare
|
@jakebailey thank you for working on this. I think the type-code key also needs to distinguish variadic functions.
For example: package main
import (
"fmt"
"reflect"
)
func main() {
fixed := reflect.TypeFor[func([]int)]()
variadic := reflect.TypeFor[func(...int)]()
fmt.Println(fixed.String(), fixed.IsVariadic())
fmt.Println(variadic.String(), variadic.IsVariadic())
}Go prints: With this change, it prints: Both types share a descriptor, so whichever signature is encountered first determines the variadic flag for both. Including the variadic flag in the type-code key should distinguish them. One non-blocking note: the |
Function types lack parameter and result metadata, so reflection cannot inspect their signatures and formats them only as func. Programs using NumIn, NumOut, In, Out, or IsVariadic need the same information as Go. Fixes 4458 For 3943 For 2650 For 2494
66e4245 to
2cfe3cf
Compare
|
Thanks @jakebailey and to @davecheney for review. Now merging. |
This adds
NumIn,NumOut,In,Out, andIsVariadic.Obviously, this begs the question "why"? Well, I do have
Call,MakeFunc, etc, all working!Fixes #4458
Fixes #6170 (well, the posted error; I suspect they want more)
For #3943
For #2650
For #2494