v.markused: support a const used as default value in struct init
parent
f68bdb7805
commit
a208138283
|
@ -33,6 +33,9 @@ pub fn (mut w Walker) mark_const_as_used(ckey string) {
|
|||
$if trace_skip_unused_marked ? {
|
||||
eprintln(' const > |$ckey|')
|
||||
}
|
||||
if w.used_consts[ckey] {
|
||||
return
|
||||
}
|
||||
w.used_consts[ckey] = true
|
||||
cfield := w.all_consts[ckey] or { return }
|
||||
w.expr(cfield.expr)
|
||||
|
@ -42,6 +45,9 @@ pub fn (mut w Walker) mark_global_as_used(ckey string) {
|
|||
$if trace_skip_unused_marked ? {
|
||||
eprintln(' global > |$ckey|')
|
||||
}
|
||||
if w.used_globals[ckey] {
|
||||
return
|
||||
}
|
||||
w.used_globals[ckey] = true
|
||||
gfield := w.all_globals[ckey] or { return }
|
||||
w.expr(gfield.expr)
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
&Symbol{
|
||||
name: 'void'
|
||||
parent: &nil
|
||||
return_type: &nil
|
||||
is_top_level: true
|
||||
generic_placeholder_len: 0
|
||||
sumtype_children_len: 0
|
||||
interface_children_len: 0
|
||||
children: []
|
||||
file_path: ''
|
||||
file_version: 0
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
&Symbol{
|
||||
name: 'void'
|
||||
parent: &nil
|
||||
return_type: &nil
|
||||
is_top_level: true
|
||||
generic_placeholder_len: 0
|
||||
sumtype_children_len: 0
|
||||
interface_children_len: 0
|
||||
children: []
|
||||
file_path: ''
|
||||
file_version: 0
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
module main
|
||||
|
||||
pub const void_type = &Symbol{
|
||||
name: 'void'
|
||||
file_path: ''
|
||||
file_version: 0
|
||||
is_top_level: true
|
||||
}
|
||||
|
||||
[heap]
|
||||
pub struct Symbol {
|
||||
pub mut:
|
||||
name string
|
||||
parent &Symbol = void_type // parent is for typedefs, aliases
|
||||
return_type &Symbol = void_type // return_type is for functions and variables
|
||||
is_top_level bool [required]
|
||||
generic_placeholder_len int
|
||||
sumtype_children_len int
|
||||
interface_children_len int
|
||||
children []&Symbol // methods, sum types, map types, optionals, struct fields, etc.
|
||||
file_path string [required] // required in order to register the symbol at its appropriate directory.
|
||||
file_version int [required] // file version when the symbol was registered
|
||||
}
|
||||
|
||||
fn main() {
|
||||
println(void_type)
|
||||
}
|
Loading…
Reference in New Issue