-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Unhandled Exception 0x149f6f0 #23522
Comments
Connected to Huly®: V_0.6-21951 |
On Linux, it looks almost the same, with just as little indication of the actual error.
|
The usage is wrong. pub struct Tree {
value string
}
pub type TreeBelt = map[string]fn (input string) []string
fn main() {
tree := Tree{
value: 'he he'
}
mut belt := TreeBelt({
"bar" : fn [tree](input string) []string {
return [tree.value + input]
}
})
mut belt2 := TreeBelt(map[string]fn (string) []string{})
belt2['bar'] = fn [tree](input string) []string {
return [tree.value + input]
}
// ok
println(belt["bar"]) // fn (string) []string
println(belt2["bar"]) // fn (string) []string
println(belt["bar"]("foo"))
println(belt2["bar"]("fo")) // ok
}
PS D:\Test\v\tt1> v run .
fn (string) []string
fn (string) []string
['he hefoo']
['he hefo'] |
Just to clarify for our eyes, I guess you mean, change this: mut belt := TreeBelt(map[string]fn (string) []string){
"bar" : fn [tree](input string) []string {
return [tree.value + input]
}
} by this: mut belt := TreeBelt({
"bar" : fn [tree](input string) []string {
return [tree.value + input]
}
})
|
why did this parse? TreeBelt(map[string]fn (string) []string){
"bar" : fn [tree](input string) []string { |
oh... it parsed as: mut belt := TreeBelt( map[string]fn (string) []string )` ... then followed by (on the same line):
|
The compiler just ignores the second map initialization expression (since it was not used for anything), and considers the first one to be a valid cast (but it should not have). |
I think that |
A more minimal reproduction is just: pub type TreeBelt = map[string]fn (input string) []string
mut tb := TreeBelt( map[string]fn (string) []string )
println(tb) which currently produces: |
Simplifying it further: mut tb := map[string]string
println(tb) |
V version: V 0.4.9 496451e, press to see full `v doctor` output
What did you do?
./v -g -o vdbg cmd/v && ./vdbg .\main.v && C:\Dev\Zone\mam_v\treevee\src\repro\main.exe
What did you see?
What did you expect to see?
Execution without Unhandled Exception error
Note
You can use the 👍 reaction to increase the issue's priority for developers.
Please note that only the 👍 reaction to the issue itself counts as a vote.
Other reactions and those to comments will not be taken into account.
The text was updated successfully, but these errors were encountered: