Skip to content

unexpect panic in json.Marshal #1116

@luoliwoshang

Description

@luoliwoshang
package main

import (
	"encoding/json"
	"fmt"
)

func main() {
	type A struct {
		A int
		B string
	}
	a := A{A: 1, B: "2"}
	json, err := json.Marshal(a)
	if err != nil {
		panic(err)
	}
	fmt.Println(string(json))
}

llgo run . got

panic: reflect: call of reflect.Value.Float on struct Value

[0x00775108 github.com/goplus/llgo/runtime/internal/runtime.Rethrow+0x37, SP = 0x6c]
[0x00746FC4 encoding/json.Marshal+0x15, SP = 0x1c4]
[0x00770C30 github.com/goplus/llcppg/_xtool/llclang/internal/parser/tt.main+0x3f, SP = 0x84]
[0x0078D750 main+0x4, SP = 0x24]
panic: exit status 2

same in macos & linux

> uname -a  
Linux be00d9b1c2c9 6.10.14-linuxkit #1 SMP Fri Nov 29 17:22:03 UTC 2024 aarch64 aarch64 aarch64 GNU/Linux
❯ uname -a
Darwin zhangzhiyangdeMacBook-Pro.local 23.6.0 Darwin Kernel Version 23.6.0: Mon Jul 29 21:14:04 PDT 2024; root:xnu-10063.141.2~1/RELEASE_ARM64_T8122 arm64

llgo version 93b9b7d

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