Skip to content

Commit 9f57c74

Browse files
committed
checker: allow mixed case macro idents (fixes libsodium build)
1 parent 483058c commit 9f57c74

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

‎vlib/v/checker/checker.v‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,15 @@ const generic_fn_cutoff_limit_per_fn = 10_000 // how many times post_process_gen
2424

2525
const generic_fn_postprocess_iterations_cutoff_limit = 1_000_000
2626

27+
fn has_ascii_upper(s string) bool {
28+
for ch in s {
29+
if ch >= `A` && ch <= `Z` {
30+
return true
31+
}
32+
}
33+
return false
34+
}
35+
2736
// array_builtin_methods contains a list of all methods on array, that return other typed arrays.
2837
// i.e. that act as *pseudogeneric* methods, that need compiler support, so that the types of the results
2938
// are properly checked.
@@ -6696,7 +6705,8 @@ fn (mut c Checker) ident(mut node ast.Ident) ast.Type {
66966705
}
66976706
c_name := node.name.all_after('C.')
66986707
if !c.pref.translated && !c.file.is_translated && c_name.len > 0 && c_name[0] >= `a`
6699-
&& c_name[0] <= `z` && c_name !in c.table.export_names.values() {
6708+
&& c_name[0] <= `z` && !has_ascii_upper(c_name)
6709+
&& c_name !in c.table.export_names.values() {
67006710
c.error('undefined C identifier: `${node.name}`', node.pos)
67016711
return ast.int_type
67026712
}

0 commit comments

Comments
 (0)