Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion registry/channels/discord.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "discord",
"display_name": "Discord Channel",
"kind": "channel",
"version": "0.2.2",
"version": "0.2.3",
"wit_version": "0.3.0",
"description": "Talk to your agent in Discord",
"keywords": [
Expand Down
2 changes: 1 addition & 1 deletion registry/channels/feishu.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "feishu",
"display_name": "Feishu / Lark Channel",
"kind": "channel",
"version": "0.1.4",
"version": "0.2.0",
"wit_version": "0.3.0",
"description": "Talk to your agent through a Feishu or Lark bot",
"keywords": [
Expand Down
2 changes: 1 addition & 1 deletion registry/channels/slack.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "slack",
"display_name": "Slack Channel",
"kind": "channel",
"version": "0.2.2",
"version": "0.3.0",
"wit_version": "0.3.0",
"description": "Talk to your agent in Slack",
"keywords": [
Expand Down
2 changes: 1 addition & 1 deletion registry/channels/telegram.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "telegram",
"display_name": "Telegram Channel",
"kind": "channel",
"version": "0.2.7",
"version": "0.2.8",
"wit_version": "0.3.0",
"description": "Talk to your agent through a Telegram bot",
"keywords": [
Expand Down
2 changes: 1 addition & 1 deletion registry/channels/whatsapp.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "whatsapp",
"display_name": "WhatsApp Channel",
"kind": "channel",
"version": "0.2.1",
"version": "0.2.2",
"wit_version": "0.3.0",
"description": "Talk to your agent through WhatsApp",
"keywords": [
Expand Down
49 changes: 46 additions & 3 deletions scripts/check_no_panics.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -347,6 +363,33 @@ def test_proc_macro_test_attrs_mark_body_only(self) -> None:
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",
Expand Down
Loading