Skip to content

cmd/compile: internal compiler error: expected struct { F uintptr; L *lua.Lua_State } value to have type struct { F uintptr; L *lua.Lua_State } #62498

@raochq

Description

@raochq

What version of Go are you using (go version)?

$ go version
go version go1.21.0 windows/amd64

Does this issue reproduce with the latest release?

This issue only occurs in go 1.21
It work well before go1.21;
It work well in go1.21 with '-gcflags "all=-l"';

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\arao\AppData\Local\go-build
set GOENV=C:\Users\arao\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=D:\NN4\server\server\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=D:\NN4\server\server\
set GOPRIVATE=
set GOPROXY=https://goproxy.cn,direct
set GOROOT=C:\go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLCHAIN=auto
set GOTOOLDIR=C:\go\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.21.0
set GCCGO=gccgo
set GOAMD64=v1
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=NUL
set GOWORK=D:\NN4\server\server\go.work
set CGO_CFLAGS=-ID:\NN4\server\server\local\include -ID:\NN4\server\server\local\include\luajit-2.1
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-O2 -g
set CGO_FFLAGS=-O2 -g
set CGO_LDFLAGS=-LD:\NN4\server\server\local\lib\windows_amd64 -ltolua -lpbc -lluajit-5.1 -lmingwex
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=C:\Users\arao\AppData\Local\Temp\go-build2469763229=/tmp/go-build -gno-record-gcc-switches

What did you do?

go install battlesvr

What did you expect to see?

build success

What did you see instead?

# nikki/golua
src\nikki\golua/luastack.go:19:12: internal compiler error: expected struct { F uintptr; L *lua.Lua_State } value to have type struct { F uintptr; L *lua.Lua_State }

Please file a bug report including a short program that triggers the error.
https://go.dev/issue/new

code

////luastack.go
package golua

import (
	"nikki/golua/lua"
	"nikki/golua/tolua"

	"fmt"
	"runtime"
	"unsafe"
)

type LuaStack struct {
	l *lua.Lua_State
}

func NewLuaStack() *LuaStack {
	L := lua.LuaL_newstate()
	lua.LuaL_openlibs(L)
	tolua.Open(L) // The problem occurs in this line
	stack := &LuaStack{
		l: L,
	}
	runtime.SetFinalizer(stack, (*LuaStack).Close)
	return stack
} 
//// tolua.go
package tolua

/*
#include <tolua/tolua.h>
#include <stdlib.h>
*/
import "C"

import (
	"nikki/golua/lua"
	"unsafe"
)
// The problem occurs in this func
func Open(L *lua.Lua_State) {
	C.tolua_open((*C.lua_State)(L))
}
////lua.go
package lua

/*
#include <lua.h>
#include <stdlib.h>

LUA_API const char *(Lua_pushfstring) (lua_State *L, const char *s) { return lua_pushfstring(L, s); }
*/
import "C"

import (
	"fmt"
	"unsafe"
)
type Lua_State C.lua_State
func LuaL_newstate() *Lua_State { return (*Lua_State)(C.luaL_newstate()) }

Metadata

Metadata

Assignees

Labels

FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.compiler/runtimeIssues related to the Go compiler and/or runtime.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions