-
-
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
compiler panic: string.repeat: count is negative: -1 #20734
Labels
Bug
This tag is applied to issues which reports bugs.
Comments
After doing a v up to "V 0.4.4 a374d25, timestamp: 2024-02-05 17:14:27 +0200" stack trace slightly more informative:
|
To contribute with this issue, I executed several tests and managed to find a solution by passing module main
struct Blob {
label int
}
// remove the mut and it works, put it in and get the error above
module main
struct Blob {
label int
}
// remove the mut and it works, put it in and get the error above
fn (mut b Blob) str() string {
return 'blob'
}
fn main() {
// Works
mut a1 := map[int]&Blob
a1[1] = &Blob{label: 4}
println('First execution ${a1}')
// Not works
//mut a2 := map[int]Blob
//a2[1] = Blob{label: 4}
//println('Second execution ${a2}')
} |
Thanks for your solution. But it would be nice if the compiler reported an
error rather than panic.
…On Tue, 6 Feb 2024 at 00:43, Vinicius Silva ***@***.***> wrote:
To contribute with this issue, I executed several tests and managed to
find a solution by passing & to reference Blob and successfully executed
with mut in the str() function. The problem lies in using mut with the
value of a map being of type Blob (struct) as in the code below:
module main
struct Blob {
label int
}
// remove the mut and it works, put it in and get the error abovemodule main
struct Blob {
label int
}
// remove the mut and it works, put it in and get the error abovefn (mut b Blob) str() string {
return 'blob'
}
fn main() {
// Works
mut a1 := map[int]&Blob
a1[1] = &Blob{label: 4}
println('First execution ${a1}')
// Not works
//mut a2 := map[int]Blob
//a2[1] = Blob{label: 4}
//println('Second execution ${a2}')
}
—
Reply to this email directly, view it on GitHub
<#20734 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AEEESAE56LCWQZVRKIQ22ETYSF4EJAVCNFSM6AAAAABC2I7AMOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMRYGU3TEMJSGM>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
Compile this code:
Reproduction Steps
Just attempt to compile the above code
Expected Behavior
Compiles OK
Current Behavior
Compiler reports:
Possible Solution
No response
Additional Information/Context
No response
V version
V 0.4.4 ac2dcc2
Environment details (OS name and version, etc.)
EndeavourOS
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: