From 9d198573192dceef66620e9fa2c8cdd067d6d384 Mon Sep 17 00:00:00 2001 From: Kiprey Date: Thu, 23 Feb 2023 20:24:15 +0800 Subject: [PATCH] fix: fix context shallow copy --- grammar.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/grammar.py b/grammar.py index ac89714..f77d7f4 100755 --- a/grammar.py +++ b/grammar.py @@ -28,6 +28,7 @@ import random import re import struct +import copy _INT_RANGES = { 'int': [-2147483648, 2147483647], @@ -283,7 +284,7 @@ def _generate_code(self, num_lines, initial_variables=[], last_var=0): self._add_variable('window', 'Window', context) while len(context['lines']) < num_lines: - tmp_context = context.copy() + tmp_context = copy.deepcopy(context) try: if (random.random() < self._interesting_line_prob) and (len(tmp_context['interesting_lines']) > 0): tmp_context['force_var_reuse'] = True