1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

checker: fix cgen error on sliced references (#13736)

This commit is contained in:
Nick Treleaven
2022-03-14 17:52:37 +00:00
committed by GitHub
parent ea3c0166c0
commit 34dd4f34ab
4 changed files with 36 additions and 6 deletions

View File

@ -106,7 +106,7 @@ pub fn (mut b Builder) go_back(n int) {
// cut_last cuts the last `n` bytes from the buffer and returns them
pub fn (mut b Builder) cut_last(n int) string {
cut_pos := b.len - n
x := unsafe { (&[]byte(b))[cut_pos..] }
x := unsafe { (*&[]byte(b))[cut_pos..] }
res := x.bytestr()
b.trim(cut_pos)
return res
@ -147,7 +147,7 @@ pub fn (b &Builder) last_n(n int) string {
if n > b.len {
return ''
}
x := unsafe { (&[]byte(b))[b.len - n..] }
x := unsafe { (*&[]byte(b))[b.len - n..] }
return x.bytestr()
}
@ -157,7 +157,7 @@ pub fn (b &Builder) after(n int) string {
if n >= b.len {
return ''
}
x := unsafe { (&[]byte(b))[n..] }
x := unsafe { (*&[]byte(b))[n..] }
return x.bytestr()
}