checker: handle unknown fields in fail_if_immutable
parent
09f6cd6a75
commit
10da871743
|
@ -49,6 +49,7 @@ pub const (
|
||||||
|
|
||||||
pub const (
|
pub const (
|
||||||
align_left = 1
|
align_left = 1
|
||||||
|
align_right = 4
|
||||||
ALIGN_RIGHT = 4
|
ALIGN_RIGHT = 4
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -44,6 +44,14 @@ pub:
|
||||||
status_code int
|
status_code int
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn new_request(method, url, data string) ?Request{
|
||||||
|
return Request{
|
||||||
|
method: method
|
||||||
|
url: url
|
||||||
|
data: data
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn get(url string) ?Response {
|
pub fn get(url string) ?Response {
|
||||||
return fetch_with_method('GET', url, FetchConfig{})
|
return fetch_with_method('GET', url, FetchConfig{})
|
||||||
}
|
}
|
||||||
|
|
|
@ -523,7 +523,11 @@ fn (mut c Checker) fail_if_immutable(expr ast.Expr) {
|
||||||
match typ_sym.kind {
|
match typ_sym.kind {
|
||||||
.struct_ {
|
.struct_ {
|
||||||
struct_info := typ_sym.info as table.Struct
|
struct_info := typ_sym.info as table.Struct
|
||||||
field_info := struct_info.get_field(it.field_name)
|
field_info := struct_info.find_field(it.field_name) or {
|
||||||
|
type_str := c.table.type_to_str(it.expr_type)
|
||||||
|
c.error('unknown field `${type_str}.$it.field_name`', it.pos)
|
||||||
|
return
|
||||||
|
}
|
||||||
if !field_info.is_mut {
|
if !field_info.is_mut {
|
||||||
type_str := c.table.type_to_str(it.expr_type)
|
type_str := c.table.type_to_str(it.expr_type)
|
||||||
c.error('field `$it.field_name` of struct `${type_str}` is immutable', it.pos)
|
c.error('field `$it.field_name` of struct `${type_str}` is immutable', it.pos)
|
||||||
|
|
Loading…
Reference in New Issue