Skip to content

Incorrect code generated with type names #28

@mharmer

Description

@mharmer

When compiling a single proto file that imports another, the referenced types don't seem to be correct:

sub.proto:

syntax = "proto3";

package Foo;

message Baz2 {
	int32 field_a = 1;
}

main.proto:

syntax = "proto3";

import "sub.proto";

package Foo;

message Baz {
	Baz2 field_a = 1;
}

Compiled with: protoc --elm_out=. main.proto sub.proto

Produces incorrect code:

-- Sub.elm
type alias Baz2 =
    { fieldA : Int -- 1
    }

-- Main.elm
type alias Baz =
    { fieldA : Maybe Foo_Baz2 -- 1
    }

Compiler error for reference:

I cannot find a `Foo_Baz2` type:

16|     { fieldA : Maybe Foo_Baz2 -- 1

It seems as though the package name is incorrectly being added to the name of the type.
As a workaround, if I comment out the package name from both proto files it seems to generate correct code.

I don't know if this falls into the unsupported 'Packages' listing in the main README.md, since it didn't list details as to why it wasn't supported.

Interestingly, this is very similar to a bug I just reported in the other Elm protoc project: eriktim/protoc-gen-elm#7

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions