mirror of
https://github.com/nearai/ironclaw.git
synced 2026-09-02 23:56:24 +08:00
fix(ci): bump 5 channel versions + fix lifetime desync in panics check (#2300)
Version bumps for channels with source changes:
- discord 0.2.2 -> 0.2.3 (pairing message UX)
- feishu 0.1.4 -> 0.2.0 (pairing flow refactor + multi-tenancy)
- slack 0.2.2 -> 0.3.0 (broadcast feature implementation)
- telegram 0.2.6 -> 0.2.8 (webhook dedup + configurable polling)
- whatsapp 0.2.0 -> 0.2.2 (pairing message UX)
Fix check_no_panics.py: Rust lifetime annotations ('static, 'a) were
parsed as char literal openings, blanking the rest of the line including
any opening brace. This caused the brace-depth tracker to desync in
large test modules, producing false positives (e.g. server.rs:6378).
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -123,9 +123,25 @@ def sanitize_line(line: str, state: LexerState) -> str:
|
||||
i += 1
|
||||
continue
|
||||
if ch == "'":
|
||||
# This can misclassify lifetimes like `'a` as char literals. That only
|
||||
# risks false negatives by masking later code on the same line.
|
||||
state.in_char = True
|
||||
# Distinguish char literals ('x', '\n') from lifetime annotations
|
||||
# ('a, 'static). Lifetimes are an apostrophe followed by an ASCII
|
||||
# letter or underscore and then a non-apostrophe (identifiers, not
|
||||
# closing-quote). Misclassifying a lifetime as a char literal
|
||||
# blanks the rest of the line, hiding braces and causing the
|
||||
# brace-depth tracker to desync across the whole file.
|
||||
if nxt and (nxt.isalpha() or nxt == "_"):
|
||||
# Peek past the identifier to see if it's 'x' (char) or 'ident (lifetime).
|
||||
j = i + 2
|
||||
while j < len(chars) and (chars[j].isalnum() or chars[j] == "_"):
|
||||
j += 1
|
||||
if j < len(chars) and chars[j] == "'":
|
||||
# Closing quote found -> char literal like 'a' or 'ab' (invalid but safe to skip).
|
||||
state.in_char = True
|
||||
else:
|
||||
# No closing quote -> lifetime annotation; skip the apostrophe.
|
||||
out[i] = " "
|
||||
else:
|
||||
state.in_char = True
|
||||
i += 1
|
||||
continue
|
||||
|
||||
@@ -347,6 +363,33 @@ class CheckNoPanicsTests(unittest.TestCase):
|
||||
self.assertFalse(contexts[4])
|
||||
self.assertFalse(contexts[5])
|
||||
|
||||
def test_lifetime_annotations_do_not_desync_braces(self) -> None:
|
||||
"""Lifetime annotations ('a, 'static) must not be parsed as char literals.
|
||||
|
||||
If they are, the sanitizer blanks the rest of the line — including any
|
||||
opening brace — and the brace-depth tracker desyncs. This caused
|
||||
false positives in large test modules (e.g. server.rs).
|
||||
"""
|
||||
lines = [
|
||||
"#[cfg(test)]\n",
|
||||
"mod tests {\n",
|
||||
" fn set_env_var(key: &'static str) -> Guard {\n",
|
||||
" let original = std::env::var(key).ok();\n",
|
||||
" Guard { key, original }\n",
|
||||
" }\n",
|
||||
" fn later_helper() {\n",
|
||||
' value.expect("should be test context");\n',
|
||||
" }\n",
|
||||
"}\n",
|
||||
]
|
||||
|
||||
contexts = line_test_contexts(lines)
|
||||
|
||||
# All lines inside mod tests must be test context, even after
|
||||
# a function signature containing a lifetime annotation.
|
||||
self.assertTrue(contexts[2], "fn with 'static should be test context")
|
||||
self.assertTrue(contexts[7], "later helper should still be test context")
|
||||
|
||||
def test_named_tests_module_marks_context(self) -> None:
|
||||
lines = [
|
||||
"mod tests {\n",
|
||||
|
||||
Reference in New Issue
Block a user