Skip to content

schema with [name: str]: Test = { name = name } is not being populated in the schema #411

@eminaktas

Description

@eminaktas

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

It looks like the types captured for TestMap in here, cannot capture Properties.

Screenshot 2024-11-22 at 23 21 10
package main

import (
	"bytes"
	"fmt"
	"os"

	"kcl-lang.io/kcl-go/pkg/tools/gen"
)

const code = `
schema Main:
	maps: TestMap

schema Test:
	name: str
	surname: str

schema TestMap:
	[name: str]: Test = {name = name}
`

func main() {
	var buf bytes.Buffer
	err := gen.GenGo(&buf, fmt.Sprintf("test.k"), code, nil)
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(1)
	}

	fmt.Println(buf.String())
}

2. What did you expect to see? (Required)

type TestMap map[string]Test

type Test struct {
    name string `kcl:"name=name,type=str"`       // kcl-type: str
    surname string `kcl:"name=surname,type=str"` // kcl-type: str
}

type Main struct {
    maps *TestMap `kcl:"name=maps,type=TestMap"` // kcl-type: TestMap
}

3. What did you see instead (Required)

type TestMap struct {
}

type Test struct {
    name string `kcl:"name=name,type=str"`       // kcl-type: str
    surname string `kcl:"name=surname,type=str"` // kcl-type: str
}

type Main struct {
    maps *TestMap `kcl:"name=maps,type=TestMap"` // kcl-type: TestMap
}

4. What is your KCL components version? (Required)

0.10.10-darwin-arm64

Metadata

Metadata

Assignees

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