Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SimpleTypeNode.TypeName returns unexpected value #37

Closed
kitagry opened this issue Dec 10, 2023 · 0 comments · Fixed by #38
Closed

SimpleTypeNode.TypeName returns unexpected value #37

kitagry opened this issue Dec 10, 2023 · 0 comments · Fixed by #38

Comments

@kitagry
Copy link
Contributor

kitagry commented Dec 10, 2023

Hi @goccy. Thank you for the nice plugin!

I want to use TypeName, but it returns unexpected values.

Sample code

func TestSimpleTypeNode_TypeName(t *testing.T) {
	stmt, err := zetasql.ParseScript("DECLARE x STRING(10);", zetasql.NewParserOptions(), zetasql.ErrorMessageOneLine)
	if err != nil {
		t.Fatal(err)
	}

	ast.Walk(stmt, func(n ast.Node) error {
		if n, ok := n.(*ast.SimpleTypeNode); ok {
			if n.TypeName() != "STRING" {
				t.Fatalf(`SimpleTypeNode.TypeName expect "STRING", got "%s"`, n.TypeName())
			}
		}
		return nil
	})
}

Environment

MacOS Ventura 13.6

$ clang++ --version
Apple clang version 14.0.0 (clang-1400.0.29.202)
Target: x86_64-apple-darwin22.6.0
Thread model: posix

$ go version
go version go1.21.4 darwin/amd64

expected

Test should pass.

actual

SimpleTypeNode.TypeName expect "STRING", got "pv�"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant