Skip to content

cmd/compile: allow typechecking loops with & #17533

@randall77

Description

@randall77
type T struct {
    p *T
}
var x = T{p: &x}

This code does not compile:

tmp1.go:7: typechecking loop involving x = T literal

I don't see any obvious reason why this wouldn't be typecheckable.

This comes up when trying to compile descriptors for recursive .proto messages.

message Recursive {
    optional Recursive x = 1;
}

The current proto compiler accepts such a message. I'm doing some experiments to optimize the proto-generated code. Part of that is having a descriptor for a Recursive message being able to point to itself (to describe its x field).

@griesemer @mdempsky @dsnet

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions