Skip to content

cl toType: support TypeElaborated - #727

Merged
xushiwei merged 5 commits into
goplus:devfrom
xushiwei:q
Sep 17, 2026
Merged

xushiwei merged 5 commits into
goplus:devfrom
xushiwei:q

Conversation

@xushiwei

Copy link
Copy Markdown
Member

No description provided.

@fennoai fennoai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review: support TypeElaborated in toType

This PR registers named class/typedef types into a new ctx.types cache (c/c++ type spelling => types.Type) and resolves elaborated types through it in toType, alongside moving loadMacro/loadTypedef from deferred ctx.compiles closures into the eager load phase. Direction is clean and the new golden fixtures verify cross-type field resolution (bar::base field -> Bar_base).

A few things worth addressing before merge — see inline comments. The main one is that an unresolved elaborated type falls through to the generic panic("todo: toType ..."), which is both hard to diagnose and a forward-reference hazard now that type resolution runs eagerly.

Non-blocking note: the two writers of ctx.types (class.go:74, compile.go:246) write blindly with no duplicate-key check. A forward-declared class and its later definition can silently overwrite. A deliberate last-writer-wins is fine, but a guard (or a short comment stating the intent) would make the invariant explicit.

Comment thread cl/type_and_var.go
Comment thread cl/_testcpp/class_with_ns/in.h Outdated
@xushiwei
xushiwei merged commit 19238a3 into goplus:dev Sep 17, 2026
2 checks passed
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 this pull request may close these issues.

1 participant