yutopp/rill

extern関数以外でのonlymeta値の計算

nekketsuuu opened this issue · 0 comments

たとえば、以下のコードをコミット8ff550bでコンパイルすると Internal Compiler Error (ICE) が起こります (Wandbox)。

ソースコード

import std.stdio

def typeof!(T)(t: T): type {
    return type;
}

def main() {
    val a = 42;
    if (typeof(a) == int32) {
        println("int32");
    } else {
        println("unknown");
    }
}

エラー出力

= LOAD_MODULE(/home/jail/prog.rill)
= LOAD_MODULE(/home/jail/prog.rill) 0.028000s
= GENERATE_CODE(prog.exe)
Fatal error: exception Failure("[ICE] failed to get a ctfed value")
Raised at file "pervasives.ml", line 32, characters 17-33
Called from file "codegen_llvm.ml", line 1831, characters 17-61
Called from file "codegen_llvm.ml", line 491, characters 26-86
Called from file "codegen_llvm.ml", line 526, characters 18-48
Called from file "codegen_llvm.ml", line 1279, characters 38-63
Called from file "list.ml", line 88, characters 24-34
Called from file "codegen_llvm.ml", line 1282, characters 4-43
Called from file "codegen_llvm.ml", line 1292, characters 4-35
Called from file "codegen_llvm.ml", line 474, characters 16-47
Called from file "codegen_llvm.ml", line 526, characters 18-48
Called from file "codegen_llvm.ml", line 717, characters 43-78
Called from file "codegen_llvm.ml", line 519, characters 26-60
Called from file "codegen_llvm.ml", line 159, characters 14-36
Called from file "codegen_llvm.ml", line 1516, characters 14-39
Called from file "codegen_llvm.ml" (inlined), line 210, characters 9-62
Called from file "codegen_llvm.ml", line 216, characters 12-50
Called from file "codegen_llvm.ml", line 159, characters 14-36
Called from file "codegen_llvm.ml", line 2302, characters 10-41
Called from file "main.ml", line 108, characters 22-55

ぶんちょうさんのこのツイートによると「extern関数以外でのonlymeta値の計算は内部的にtemplate相当に変換する必要があるのですが、それをさぼってダミーをハードコードしているためICEになっている」そうです。