From 160c0373559ba82c472ffcfe355401fa343f71c5 Mon Sep 17 00:00:00 2001 From: Evan Hubinger Date: Sat, 19 Oct 2024 23:22:33 -0700 Subject: [PATCH] Fix pypy issue --- coconut/compiler/compiler.py | 4 +++- coconut/compiler/util.py | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/coconut/compiler/compiler.py b/coconut/compiler/compiler.py index 3cb6371e..d9acfbd8 100644 --- a/coconut/compiler/compiler.py +++ b/coconut/compiler/compiler.py @@ -2406,7 +2406,7 @@ def split_docstring(self, block): return first_line, rest_of_lines return None, block - def tre_return_handle(self, func_name, func_args, func_store, mock_var, loc, tokens): + def tre_return_handle(self, func_name, func_args, func_store, mock_var, original, loc, tokens): """Handler for tre_return_grammar.""" args = ", ".join(tokens) @@ -2446,6 +2446,8 @@ def tre_return_handle(self, func_name, func_args, func_store, mock_var, loc, tok type_ignore=self.type_ignore_comment(), ) + tre_return_handle.trim_arity = False # fixes pypy issue + def tre_return_grammar(self, func_name, func_args, func_store, mock_var=None): """Generate grammar element that matches a string which is just a TRE return statement.""" self.tre_func_name <<= base_keyword(func_name).suppress() diff --git a/coconut/compiler/util.py b/coconut/compiler/util.py index 5dcfa3e4..3edb4090 100644 --- a/coconut/compiler/util.py +++ b/coconut/compiler/util.py @@ -751,6 +751,8 @@ def cached_parse( # only iterate over keys, not items, so we don't mark everything as alive for key in computation_graph_cache: prefix, is_at_end = key + if DEVELOP: # avoid overhead + internal_assert(cache_prefixes or is_at_end, "invalid computation graph cache item", key) # the assumption here is that if the prior parse didn't make it to the end, # then we can freely change the text after the end of where it made it, # but if it did make it to the end, then we can't add more text after that