fix(cl): preserve imports for types initialized across files
I maintainer di solito rispondono entro 1 giorno
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 22/100
Direzione di ricerca
Start with the minimal reproduction: a forward declaration in a.h and the definition in b.h, mapped to separate outputs through GoFileOf. Check which Go file receives the imports for Point, and why c.Int and unsafe.Pointer end up in a file without them. Pull request #1042 is already open against this issue, so coordinate with it first. Done means a.go compiles with the right imports and aliases stay consistent regardless of traversal order.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Summary
When a C/C++ record is declared in one header and defined in another header,
llcppg can generate the record in the Go file that owns the declaration while
collecting its field types from the definition's Go file. The generated type
then refers to imported types such as c.Int or unsafe.Pointer, but the
imports are attached to the wrong Go file.
Depending on source/file traversal order, this produces either missing imports
or inconsistent aliases such as c1.Int and unsafe1.Pointer.
Minimal Reproduction
a.h:
#pragma once
struct point;
b.h:
#pragma once
struct point {
int x;
void *data;
};
Generate one Go package from both headers and map them to separate output files:
GoFileOf("a.h") == "a.go"
GoFileOf("b.h") == "b.go"
The forward declaration creates Point in a.go. The later definition fills
that type with c.Int and unsafe.Pointer fields.
Actual Result
a.go can be generated as:
package multifile
type Point struct {
X c.Int
Data unsafe.Pointer
}
but without the corresponding imports in a.go, resulting in undefined
identifiers. In larger bindings the same issue can instead appear as an alias
mismatch, for example an import of c with references to c1, or an import of
unsafe1 with references to unsafe.
Expected Result
The imports required by Point must be emitted in the same Go file as the
type declaration:
package multifile
import (
"github.com/goplus/lib/c"
"unsafe"
)
type Point struct {
X c.Int
Data unsafe.Pointer
}
Import aliases and all references must agree within every generated Go file,
regardless of header traversal order.
Environment
- llcppg current main branch
- LLGo toolchain
- C language mode
- Multiple generated Go files selected through
GoFileOf
- Lingua principale
- Go
- Stelle
- 39
- Fork
- 13
- Merge medio
- 1h 28m
- PR unite (30g)
- 256
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di goplus/llcppg
-
bug
Difficoltà 5/5 Più di una settimana Idoneità per principianti 28/100
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 4/5 3-5 giorni Idoneità per principianti 55/100
I maintainer di solito rispondono entro 1 giorno
-
feature proposal
Difficoltà 5/5 Più di una settimana Idoneità per principianti 18/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
I maintainer di solito rispondono entro 1 giorno
-
Architecture-Design feature to be confirm
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di goplus/llcppg
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
SAP/crossplane-provider-btp#1118 ·
I maintainer di solito rispondono entro 1 giorno
-
benchmark: `make setup` fails because audit-exporter builds with Go 1.25.0 while go.mod requires 1.26.0Forse già presa @xsvm l’ha presa oggi. Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 84/100
volcano-sh/volcano#6097 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
I maintainer di solito rispondono entro 1 giorno
-
os: RawConn methods of a closed File return internal/poll.ErrFileClosing instead of ErrClosedAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
[Bug]: Bedrock invoke-with-response-stream reports `stop_reason: "end_turn"` for tool-use turnsAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
I maintainer di solito rispondono entro 1 giorno