Skip to content

redefining symbols and calling undefined symbols should be illegal #178

@kazuya00

Description

@kazuya00

give this example:
i tryed these tests and everyone passes the transpiler silently.

struct Point {
    x: int;
    y: int;
}
// struct redefinition
struct Point {
    x: int;
    y: int;
}

trait Shape {
    fn draw(self);
}
// trait redefinition
trait Shape {
    fn draw(self);
}

// event implementation redefinition
impl Shape for Point {
    // Static method (constructor convention)
    fn new(x: int, y: int) -> Self {
        return Point{x: x, y: y};
    }
   // Static method redefinition
    fn new(x: int, y: int) -> Self {
        return Point{x: x, y: y};
    }

    // Instance method
    fn draw(self) -> void {
        println "draw point {self.x} {self.y}";
    }
    // Instance method redefinition
    fn draw(self) -> void {
        println "draw point {self.x} {self.y}";
    }
}

impl Shape for Point {
    // Static method (constructor convention)
    fn new(x: int, y: int) -> Self {
        return Point{x: x, y: y};
    }
   // Static method redefinition
    fn new(x: int, y: int) -> Self {
        return Point{x: x, y: y};
    }

    // Instance method
    fn draw(self) -> void {
        println "draw point {self.x} {self.y}";
    }
    // Instance method redefinition
    fn draw(self) -> void {
        println "draw point {self.x} {self.y}";
    }
}

fn main() {
 // indefined function 
  let h = new();
  h.draw();
  
  // indefined function and variable redefintion 
  let h = new(2, 3);
  h.draw();
  
  // wrong usage
  let h = Point();
  h.draw();
  
  // wrong usage
  let h = Point(2, 3);
  h.draw();

  // indefined instance method
  let h = Point::new(2, 3);
  h.drawing();
  
  // what is this
  nothing::nothing

  // indefined static method
  let h = Point::nothing(2, 3);
  h.draw();
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions