diff --git a/CHANGELOG.md b/CHANGELOG.md index 43844ac5..375f7702 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ - Fix array in-place op (`+=`, `-=`) adjoints to compute gradients correctly in the backwards pass. - `wp.sim.Model.edge_indices` now includes boundary edges - Allow shadowing builtin functions ([GH-308](https://github.com/NVIDIA/warp/issues/308)) +- Fix a bug in which Python docstrings would be created as local function variables in generated code. ## [1.3.3] - 2024-09-04 diff --git a/warp/codegen.py b/warp/codegen.py index ee1517ed..880b3bf2 100644 --- a/warp/codegen.py +++ b/warp/codegen.py @@ -1493,6 +1493,9 @@ def end_while(adj): def emit_FunctionDef(adj, node): for f in node.body: + # Skip variable creation for standalone constants, including docstrings + if isinstance(f, ast.Expr) and isinstance(f.value, ast.Constant): + continue adj.eval(f) if adj.return_var is not None and len(adj.return_var) == 1: