-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-type-systemArea: Type systemArea: Type systemC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.I-hangIssue: The compiler never terminates, due to infinite loops, deadlock, livelock, etc.Issue: The compiler never terminates, due to infinite loops, deadlock, livelock, etc.P-lowLow priorityLow priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
Can't compile:
enum Nil {Nil}
struct Cons<T> {head:int, tail:T}
trait Dot {fn dot(other:self) -> int;}
impl Nil:Dot {
fn dot(_:Nil) -> int {0}
}
impl<T:Dot> Cons<T>:Dot {
fn dot(other:Cons<T>) -> int {
self.head * other.head + self.tail.dot(other.tail)
}
}
fn test<T:Dot> (n:int, i:int, first:T, second:T) ->int {
match n {
0 => {first.dot(second)}
_ => {test (n-1, i+1, Cons {head:2*i+1, tail:first}, Cons{head:i*i, tail:second})}
}
}
fn main() {
let n = test(5, 0, Nil, Nil);
io::println(fmt!("%d", n));
}
Same code in Java, C# or Haskell works.
GenaritoRudxain
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-type-systemArea: Type systemArea: Type systemC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.I-hangIssue: The compiler never terminates, due to infinite loops, deadlock, livelock, etc.Issue: The compiler never terminates, due to infinite loops, deadlock, livelock, etc.P-lowLow priorityLow priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.