-
-
Notifications
You must be signed in to change notification settings - Fork 197
Open
Labels
bugSomething isn't workingSomething isn't workinggood first issueGood for newcomersGood for newcomers
Description
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();
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workinggood first issueGood for newcomersGood for newcomers