Skip to content

Autoderef on trait methods in a monomorphized caller doesn't work #3305

Closed

Description

@nikomatsakis

The following crashes:

trait double {
    fn double() -> uint;
}

impl uint: double {
    fn double() -> uint { self * 2u }
}

fn is_equal<D: double>(x: @D, exp: uint) {
    assert x.double() == exp;
}

fn main() {
    let x = @(3u as double);
    is_equal(x, 6);
}

This is because the autoderef code is not being used if the call occurs in a monomorphized context. My trans refactoring should fix this.

Activity

  1. catamorphism commented on Sep 6, 2012

    @catamorphism
    Contributor

    This works now; I pushed the test case.

  2. added a commit that references this issue on Feb 25, 2024
  3. added a commit that references this issue on Aug 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-codegenArea: Code generationI-crashIssue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions