From d7f35caed4a4a754f616f1c216223a3b7af1861f Mon Sep 17 00:00:00 2001 From: William Goode Date: Sun, 9 Aug 2026 22:03:58 -0400 Subject: [PATCH 1/2] map: raise TypeError when called with no iterables Assisted-by: Claude Code:claude-fable-5 --- crates/vm/src/builtins/map.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/crates/vm/src/builtins/map.rs b/crates/vm/src/builtins/map.rs index 4dda9caf211..cb8db23e640 100644 --- a/crates/vm/src/builtins/map.rs +++ b/crates/vm/src/builtins/map.rs @@ -37,9 +37,12 @@ impl Constructor for PyMap { fn py_new( _cls: &Py, (mapper, iterators, args): Self::Args, - _vm: &VirtualMachine, + vm: &VirtualMachine, ) -> PyResult { let iterators = iterators.into_vec(); + if iterators.is_empty() { + return Err(vm.new_type_error("map() must have at least two arguments.")); + } let strict = Radium::new(args.strict.unwrap_or(false)); Ok(Self { mapper, From 6769e2ed17b1a7e0e0cb7d6af229856de29e7336 Mon Sep 17 00:00:00 2001 From: William Goode Date: Sun, 9 Aug 2026 22:04:07 -0400 Subject: [PATCH 2/2] add test for map with no iterables Assisted-by: Claude Code:claude-fable-5 --- extra_tests/snippets/builtin_map.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/extra_tests/snippets/builtin_map.py b/extra_tests/snippets/builtin_map.py index 559d108e38b..e6e71a8124b 100644 --- a/extra_tests/snippets/builtin_map.py +++ b/extra_tests/snippets/builtin_map.py @@ -24,6 +24,13 @@ def __iter__(self): assert next(it) == 2 assert next(it) == 3 +# test for no iterables +try: + map(lambda: 1) + assert False, "TypeError expected at map construction" +except TypeError as e: + assert str(e) == "map() must have at least two arguments." + def mapping(x): if x == 0: