Skip to content

1.42.0-beta1 regression - LLVM ERROR: Broken module found #5038

@pinver

Description

@pinver

Compiles fine in 1.41.0

// LDC2 1.42.0 LLVM bug minimal reproduction
// Compile: ldc2 --preview=dip1000 standalone_test.d
// Error: "Referring to an instruction in another function!" + "LLVM ERROR: Broken module"
module standalone_test;

struct Column { string name; }
struct Table { Column[string] columns; }
struct Schema { Table[string] tables; }
struct Database(int E) { Schema[string] schemas; }

auto makeDB() => immutable Database!1(["s": immutable Schema(["t": immutable Table(["c": immutable Column("c")])])]);
enum immutable(Schema) schema = makeDB().schemas["s"];

struct S(const Schema s) {
    auto f(string x)() {
        static string g() { return (*("t" in s.tables)).columns.length > 0 ? "y" : "n"; }
        enum v = g();
        return R();
    }
    struct R { string front() => ""; }
}

alias Row = typeof(S!schema().f!"x".front);
void main() {}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions