Skip to content

Commit 45ae13c

Browse files
jgarzikclaude
andcommitted
cc: add test ensuring SUPPORTED_BUILTINS and kw BUILTIN tags stay in sync
Cross-checks that every entry in the SUPPORTED_BUILTINS string list is pre-interned in kw.rs with the BUILTIN tag, preventing the two sources from silently diverging. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 4f4f46d commit 45ae13c

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

cc/builtins.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ pub fn is_builtin_id(id: crate::strings::StringId) -> bool {
128128
#[cfg(test)]
129129
mod tests {
130130
use super::*;
131+
use crate::strings::StringTable;
131132

132133
#[test]
133134
fn test_is_builtin() {
@@ -137,4 +138,21 @@ mod tests {
137138
assert!(!is_builtin("__builtin_nonexistent"));
138139
assert!(!is_builtin("printf"));
139140
}
141+
142+
/// Verify every SUPPORTED_BUILTINS entry has the BUILTIN tag in kw.rs,
143+
/// ensuring the string list and tag-based lookup can never diverge.
144+
#[test]
145+
fn test_supported_builtins_match_kw_tags() {
146+
let table = StringTable::new();
147+
for &name in SUPPORTED_BUILTINS {
148+
let id = table
149+
.lookup(name)
150+
.unwrap_or_else(|| panic!("builtin '{}' not pre-interned in kw.rs", name));
151+
assert!(
152+
is_builtin_id(id),
153+
"builtin '{}' is in SUPPORTED_BUILTINS but missing BUILTIN tag in kw.rs",
154+
name
155+
);
156+
}
157+
}
140158
}

0 commit comments

Comments
 (0)