Skip to content

Commit f45fc45

Browse files
authored
ast, checker, fmt: fix compiler internal formatting failed (#18356)
1 parent 632c466 commit f45fc45

File tree

5 files changed

+18
-22
lines changed

5 files changed

+18
-22
lines changed

vlib/v/ast/cflags.v

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
module ast
55

66
import v.cflag
7-
import v.checker.constants
87

98
// check if cflag is in table
109
pub fn (t &Table) has_cflag(flag cflag.CFlag) bool {
@@ -27,7 +26,7 @@ pub fn (mut t Table) parse_cflag(cflg string, mod string, ctimedefines []string)
2726
}
2827
mut fos := ''
2928
mut allowed_os_overrides := []string{}
30-
allowed_os_overrides << constants.valid_comptime_not_user_defined
29+
allowed_os_overrides << valid_comptime_not_user_defined
3130
allowed_os_overrides << ctimedefines
3231
for os_override in allowed_os_overrides {
3332
if !flag.starts_with(os_override) {

vlib/v/checker/constants/constants.v renamed to vlib/v/ast/comptime_valid_idents.v

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module constants
1+
module ast
22

33
pub const (
44
valid_comptime_if_os = ['windows', 'ios', 'macos', 'mach', 'darwin', 'hpux', 'gnu',
@@ -16,10 +16,10 @@ pub const (
1616

1717
fn all_valid_comptime_idents() []string {
1818
mut res := []string{}
19-
res << constants.valid_comptime_if_os
20-
res << constants.valid_comptime_if_compilers
21-
res << constants.valid_comptime_if_platforms
22-
res << constants.valid_comptime_if_cpu_features
23-
res << constants.valid_comptime_if_other
19+
res << ast.valid_comptime_if_os
20+
res << ast.valid_comptime_if_compilers
21+
res << ast.valid_comptime_if_platforms
22+
res << ast.valid_comptime_if_cpu_features
23+
res << ast.valid_comptime_if_other
2424
return res
2525
}

vlib/v/checker/checker.v

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import v.util
1212
import v.util.version
1313
import v.errors
1414
import v.pkgconfig
15-
import v.checker.constants
1615

1716
const (
1817
int_min = int(0x80000000)
@@ -1822,7 +1821,7 @@ fn (mut c Checker) stmt(node_ ast.Stmt) {
18221821
for i, ident in node.defer_vars {
18231822
mut id := ident
18241823
if mut id.info is ast.IdentVar {
1825-
if id.comptime && id.name in constants.valid_comptime_not_user_defined {
1824+
if id.comptime && id.name in ast.valid_comptime_not_user_defined {
18261825
node.defer_vars[i] = ast.Ident{
18271826
scope: 0
18281827
name: ''

vlib/v/checker/comptime.v

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import v.pref
88
import v.token
99
import v.util
1010
import v.pkgconfig
11-
import v.checker.constants
1211

1312
[inline]
1413
fn (mut c Checker) get_comptime_var_type(node ast.Expr) ast.Type {
@@ -101,8 +100,8 @@ fn (mut c Checker) comptime_call(mut node ast.ComptimeCall) ast.Type {
101100
node.embed_file.apath = escaped_path
102101
}
103102
// c.file.embedded_files << node.embed_file
104-
if node.embed_file.compression_type !in constants.valid_comptime_compression_types {
105-
supported := constants.valid_comptime_compression_types.map('.${it}').join(', ')
103+
if node.embed_file.compression_type !in ast.valid_comptime_compression_types {
104+
supported := ast.valid_comptime_compression_types.map('.${it}').join(', ')
106105
c.error('not supported compression type: .${node.embed_file.compression_type}. supported: ${supported}',
107106
node.pos)
108107
}
@@ -526,7 +525,7 @@ fn (mut c Checker) evaluate_once_comptime_if_attribute(mut node ast.Attr) bool {
526525
}
527526
if node.ct_expr is ast.Ident {
528527
if node.ct_opt {
529-
if node.ct_expr.name in constants.valid_comptime_not_user_defined {
528+
if node.ct_expr.name in ast.valid_comptime_not_user_defined {
530529
c.error('option `[if expression ?]` tags, can be used only for user defined identifiers',
531530
node.pos)
532531
node.ct_skip = true
@@ -536,7 +535,7 @@ fn (mut c Checker) evaluate_once_comptime_if_attribute(mut node ast.Attr) bool {
536535
node.ct_evaled = true
537536
return node.ct_skip
538537
} else {
539-
if node.ct_expr.name !in constants.valid_comptime_not_user_defined {
538+
if node.ct_expr.name !in ast.valid_comptime_not_user_defined {
540539
c.note('`[if ${node.ct_expr.name}]` is deprecated. Use `[if ${node.ct_expr.name} ?]` instead',
541540
node.pos)
542541
node.ct_skip = node.ct_expr.name !in c.pref.compile_defines
@@ -729,20 +728,20 @@ fn (mut c Checker) comptime_if_branch(cond ast.Expr, pos token.Pos) ComptimeBran
729728
}
730729
ast.Ident {
731730
cname := cond.name
732-
if cname in constants.valid_comptime_if_os {
731+
if cname in ast.valid_comptime_if_os {
733732
mut is_os_target_equal := true
734733
if !c.pref.output_cross_c {
735734
target_os := c.pref.os.str().to_lower()
736735
is_os_target_equal = cname == target_os
737736
}
738737
return if is_os_target_equal { .eval } else { .skip }
739-
} else if cname in constants.valid_comptime_if_compilers {
738+
} else if cname in ast.valid_comptime_if_compilers {
740739
return if pref.cc_from_string(cname) == c.pref.ccompiler_type {
741740
.eval
742741
} else {
743742
.skip
744743
}
745-
} else if cname in constants.valid_comptime_if_platforms {
744+
} else if cname in ast.valid_comptime_if_platforms {
746745
if cname == 'aarch64' {
747746
c.note('use `arm64` instead of `aarch64`', pos)
748747
}
@@ -756,9 +755,9 @@ fn (mut c Checker) comptime_if_branch(cond ast.Expr, pos token.Pos) ComptimeBran
756755
'rv32' { return if c.pref.arch == .rv32 { .eval } else { .skip } }
757756
else { return .unknown }
758757
}
759-
} else if cname in constants.valid_comptime_if_cpu_features {
758+
} else if cname in ast.valid_comptime_if_cpu_features {
760759
return .unknown
761-
} else if cname in constants.valid_comptime_if_other {
760+
} else if cname in ast.valid_comptime_if_other {
762761
match cname {
763762
'apk' {
764763
return if c.pref.is_apk { .eval } else { .skip }

vlib/v/fmt/fmt.v

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import strings
77
import v.ast
88
import v.util
99
import v.pref
10-
import v.checker.constants
1110

1211
const (
1312
bs = '\\'
@@ -2009,7 +2008,7 @@ pub fn (mut f Fmt) enum_val(node ast.EnumVal) {
20092008

20102009
pub fn (mut f Fmt) ident(node ast.Ident) {
20112010
if node.info is ast.IdentVar {
2012-
if node.comptime && node.name in constants.valid_comptime_not_user_defined {
2011+
if node.comptime && node.name in ast.valid_comptime_not_user_defined {
20132012
f.write(node.name)
20142013
return
20152014
}

0 commit comments

Comments
 (0)