[nem-bug] [Nemerle 0000921]: Type inference fails due to ICE
feedback at nemerle.org
feedback at nemerle.org
Wed Jul 4 21:04:41 CEST 2007
A NOTE has been added to this issue.
======================================================================
<http://nemerle.org/bugs/view.php?id=921>
======================================================================
Reported By: nikov
Assigned To:
======================================================================
Project: Nemerle
Issue ID: 921
Category: Compiler
Reproducibility: always
Severity: major
Priority: normal
Status: new
======================================================================
Date Submitted: 02-20-2007 12:28 CET
Last Modified: 07-04-2007 21:04 CEST
======================================================================
Summary: Type inference fails due to ICE
Description:
[nemerle]
using System;
using System.Console;
using Nemerle.Utility;
module Program
{
Main() : void
{
def power(f, n) {
match(n) {
| 0 => (x => x)
| 1 => f
| _ => (x => f(power(f, n - 1)(x)))
}
}
def g(k) { k + 1 }
def i = power(g, 5)(3);
WriteLine(i);
_ = ReadKey();
}
}
[/nemerle]
[output]
C:\Program Files\Nemerle\Nemerle.MSBuild.targets(167,9):Error: types ? ->
? and ? -> ? are not compatible [during intersection]
C:\Program Files\Nemerle\Nemerle.MSBuild.targets(167,9):Error: internal
compiler error: assertion ''res'' failed in file ncc\typing\TyVar.n, line
392:
failed to fixate ? -> ? [] with ? -> ?
at Nemerle.Compiler.TyVar._N__FT_Fixate_2140() in
C:\Nemerle\ncc\typing\TyVar.n:line 392
at Nemerle.Compiler.TyVar.Fixate() in
C:\Nemerle\ncc\typing\TyVar.n:line 368
at Nemerle.Compiler.TyVar.Fix() in C:\Nemerle\ncc\typing\TyVar.n:line
301
at Nemerle.Compiler.Typer.NonLiteralCast(TExpr expr, TyVar target) in
C:\Nemerle\ncc\typing\Typer.n:line 953
at Nemerle.Compiler.Typer.TryAddCastTo(TExpr expr, TyVar target) in
C:\Nemerle\ncc\typing\Typer.n:line 997
at Nemerle.Compiler.Typer.AddCastTo(TExpr expr, TyVar target, String
place) in C:\Nemerle\ncc\typing\Typer.n:line 852
at Nemerle.Compiler.Typer.RunTyper() in
C:\Nemerle\ncc\typing\Typer.n:line 342
at Nemerle.Compiler.Typer..ctor(Typer parent, Fun_header fn) in
C:\Nemerle\ncc\typing\Typer.n:line 253
at Nemerle.Compiler.CompilerComponentsFactory.CreateTyper(Typer
parent, Fun_header fn) in C:\Nemerle\ncc\misc\ComponentsFactory.n:line 33
at Nemerle.Compiler.Typer.TypeLocalFunction(list`1 functions) in
C:\Nemerle\ncc\typing\Typer.n:line 1862
at Nemerle.Compiler.Typer.DoType(PExpr expression, TyVar expected,
Boolean is_toplevel_in_seq) in C:\Nemerle\ncc\typing\Typer.n:line 1246
at Nemerle.Compiler.Typer.TypeExpr(PExpr e, TyVar expected, Boolean
is_toplevel_in_seq) in C:\Nemerle\ncc\typing\Typer.n:line 1070
at Nemerle.Compiler.Typer.DoType(PExpr expression, TyVar expected,
Boolean is_toplevel_in_seq) in C:\Nemerle\ncc\typing\Typer.n:line 1627
at Nemerle.Compiler.Typer.TypeExpr(PExpr e, TyVar expected, Boolean
is_toplevel_in_seq) in C:\Nemerle\ncc\typing\Typer.n:line 1070
at Nemerle.Compiler.Typer.TypeExpr(PExpr e, TyVar expected) in
C:\Nemerle\ncc\typing\Typer.n:line 1048
at Nemerle.Compiler.Typer.TypeExpr(PExpr e) in
C:\Nemerle\ncc\typing\Typer.n:line 1042
at Nemerle.Compiler.Typer.RunTyper() in
C:\Nemerle\ncc\typing\Typer.n:line 340
at Nemerle.Compiler.Typer..ctor(MethodBuilder m) in
C:\Nemerle\ncc\typing\Typer.n:line 175
at
Nemerle.Compiler.CompilerComponentsFactory.CreateTyper(MethodBuilder m) in
C:\Nemerle\ncc\misc\ComponentsFactory.n:line 33
at Nemerle.Compiler.MethodBuilder.RunBodyTyper() in
C:\Nemerle\ncc\hierarchy\ClassMembers.n:line 811
at Nemerle.Compiler.MethodBuilder.Compile() in
C:\Nemerle\ncc\generation\HierarchyEmitter.n:line 972
at Nemerle.Compiler.TypeBuilder.EmitImplementation() in
C:\Nemerle\ncc\generation\HierarchyEmitter.n:line 564
at
Nemerle.Compiler.TypesManager._N_emit_impl_36087.apply_void(TypeBuilder
_N_36086) in C:\Nemerle\ncc\generation\HierarchyEmitter.n:line 316
at
Nemerle.Compiler.TypesManager._N_maybe_f_36693.apply_void(TypeBuilder
_N_36692) in C:\Nemerle\ncc\hierarchy\TypesManager.n:line 225
at Nemerle.Collections.List.Iter['a](list`1 l, FunctionVoid`1 f) in
C:\Nemerle\lib\list.n:line 906
at Nemerle.Core.list`1.Iter(FunctionVoid`1 f) in
C:\Nemerle\lib\list.n:line 307
at Nemerle.Compiler.TypesManager.Iter(list`1 builders, FunctionVoid`1
f) in C:\Nemerle\ncc\hierarchy\TypesManager.n:line 231
at Nemerle.Compiler.TypesManager.Iter(FunctionVoid`1 f) in
C:\Nemerle\ncc\hierarchy\TypesManager.n:line 242
at Nemerle.Compiler.TypesManager.compile_all_tyinfos(Boolean
aux_phase) in C:\Nemerle\ncc\generation\HierarchyEmitter.n:line 340
at Nemerle.Compiler.TypesManager._N__N_l35520_35623.apply_void() in
C:\Nemerle\ncc\generation\HierarchyEmitter.n:line 205
at Nemerle.Compiler.Solver.Enqueue(FunctionVoid action) in
C:\Nemerle\ncc\typing\Solver.n:line 197
at Nemerle.Compiler.TypesManager.EmitDecls() in
C:\Nemerle\ncc\generation\HierarchyEmitter.n:line 204
at Nemerle.Compiler.ManagerClass.Run() in
C:\Nemerle\ncc\passes.n:line 432
at Nemerle.CommandlineCompiler.MainClass.main_with_catching() in
C:\Nemerle\ncc\main.n:line 86
Done building project "NemerleApplication4.nproj" -- FAILED.
[/output]
======================================================================
----------------------------------------------------------------------
nikov - 02-20-07 12:36
----------------------------------------------------------------------
Minor hint helps.
def power(f : _ -> _, n) {
or
| 1 => f(_)
Nevertheless, should work without a hint.
----------------------------------------------------------------------
nikov - 02-20-07 12:56
----------------------------------------------------------------------
Well, now I see that branch
| 1 => f
is redundant. But I still does not understand, why it breaks inference...
----------------------------------------------------------------------
divan - 07-04-07 21:04
----------------------------------------------------------------------
There is no inheritance for functions. (or is there?)
So maybe just in Solver.Intersect add one more case:
| (MType.Fun (p1, r1), MType.Fun (p2, r2)) =>
_ = p1.Unify (p2);
_ = r1.Unify (r2);
[MType.Fun (p1, r1)]
At least on this example it works :)
Issue History
Date Modified Username Field Change
======================================================================
02-20-07 12:28 nikov New Issue
02-20-07 12:36 nikov Note Added: 0001759
02-20-07 12:56 nikov Note Added: 0001760
06-28-07 23:12 divan Issue Monitored: divan
07-04-07 21:04 divan Note Added: 0001933
======================================================================
More information about the bugs
mailing list