Skip to content

reflect.TypeOf got empty reflect.Type.Name() #1412

@luoliwoshang

Description

@luoliwoshang
package main

import (
	"fmt"
	"reflect"
)

func main() {
	// Test reflect on int value 42
	value := 42

	rv := reflect.ValueOf(value)
	rt := reflect.TypeOf(value)

	fmt.Printf("Value: %v\n", rv.Interface())
	fmt.Printf("Kind: %v\n", rt.Kind())
	fmt.Printf("Name: %v\n", rt.Name())

	// Verify expectations
	if rt.Kind() != reflect.Int {
		panic(fmt.Sprintf("Expected kind Int, got %v", rt.Kind()))
	}
	if rt.Name() != "int" {
		panic(fmt.Sprintf("Expected name int, got %v", rt.Name()))
	}

	fmt.Println("✓ Reflect test passed!")
}

expect same as go

_demo/go/gotypes on  main [$?] via 🐹 v1.24.6 
❯ go run reflect_simple.go  
Value: 42
Kind: int
Name: int
✓ Reflect test passed!

but got follow at llgo

Value: 42
Kind: int
Name: 
panic: Expected name int, got 

[0x02687A84 command-line-arguments.main+0x1b, SP = 0x3a4]
[0x026A83D4 main+0x4, SP = 0x24]
exit status 2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions