Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I found a bug? 2 #3033

Closed
bronze1man opened this issue Dec 10, 2019 · 3 comments
Closed

I found a bug? 2 #3033

bronze1man opened this issue Dec 10, 2019 · 3 comments
Labels
Bug This tag is applied to issues which reports bugs. OS: Playground Bugs/feature requests, that are specific to play.vlang.io.

Comments

@bronze1man
Copy link

V version:
OS:
https://vlang.io/play

What did you do?

struct Vec {
	x int
	y int
}

fn (a Vec) str() string {
	return '{$a.x, $a.y}'
}

fn (a Vec) + (b Vec) Vec {
	return a+b
}

fn (a Vec) - (b Vec) Vec {
	return Vec {
		a.x - b.x,
		a.y - b.y
	}
}

fn main() {
	a := Vec{2, 3}
	b := Vec{4, 5}
	println(a + b) 
	println(a - b) 
}

error:

You just found a bug. V can't compile this program, but it should. Please create a GitHub issue.
@bronze1man bronze1man added the Bug This tag is applied to issues which reports bugs. label Dec 10, 2019
@zeddidragon
Copy link

fn (a Vec) + (b Vec) Vec {
	return a+b
}

The implementation is an infinite recursion, I'm guessing the mistake is there.

Not a very helpful error message, of course.

@M4SSD35TRUCT10N M4SSD35TRUCT10N added the OS: Playground Bugs/feature requests, that are specific to play.vlang.io. label Dec 12, 2019
@chanbakjsd
Copy link
Contributor

It compiles on V 0.1.24 938f27e.
It crashes due to stack overflow just like expected.

Please reopen this issue if you were not satisfied by this.

@bronze1man
Copy link
Author

new error in https://vlang.io/play

.str() methods must be declared as public
    4| }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug This tag is applied to issues which reports bugs. OS: Playground Bugs/feature requests, that are specific to play.vlang.io.
Projects
None yet
Development

No branches or pull requests

4 participants