mirror of
https://github.com/vlang/v.git
synced 2025-09-14 06:52:36 +03:00
require unsafe
for dereferencing
This commit is contained in:
parent
c7f3413d70
commit
fdf6682254
3 changed files with 9 additions and 1 deletions
|
@ -1481,6 +1481,10 @@ fn (p mut Parser) get_var_type(name string, is_ptr bool, is_deref bool) string {
|
|||
mut typ := p.var_expr(v)
|
||||
// *var
|
||||
if is_deref {
|
||||
if !p.inside_unsafe {
|
||||
p.warn('dereferencing can only be done inside an `unsafe` block')
|
||||
}
|
||||
|
||||
if !typ.contains('*') && !typ.ends_with('ptr') {
|
||||
println('name="$name", t=$v.typ')
|
||||
p.error('dereferencing requires a pointer, but got `$typ`')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue