Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash on "no tests no args" input #5

Open
vivekhaldar opened this issue Feb 17, 2023 · 0 comments
Open

Crash on "no tests no args" input #5

vivekhaldar opened this issue Feb 17, 2023 · 0 comments

Comments

@vivekhaldar
Copy link

On the following input (calc_no_tests_no_args.ss):

given a string containing numbers and operators in reverse polish notation, calculate the result. The expression is given as a list of numbers and operators. Each number may be one of the following: integer, float. You can assume that the expression is always valid.

I get the following backtrace:

python3 parsel.py ./programs/calc_no_tests_no_args.ss  -g -n
python3 parsel.py ./programs/calc_no_tests_no_args.ss  -g -n
Added args: ['rpn_calculator(expression)', 'stack = []', 'for item in expression:', 'if is_number(item):', 'stack.append(item)', 'else:', 'stack.append(apply_operator(item, stack.pop(), stack.pop()))', 'return stack.pop()']
Added args: ['calculate_rpn(expression)', 'stack = []', 'for item in expression:', "if item in '+-*/':", 'b = stack.pop()', 'a = stack.pop()', 'stack.append(eval(a + item + b))', 'else:', 'stack.append(item)', 'return stack[0]']
Added args: ['rpn_calculator(expression)', 'stack = []', 'for item in expression:', 'if is_number(item):', 'stack.append(item)', 'else:', 'stack.append(apply_operator(item, stack.pop(), stack.pop()))', 'return stack.pop()']
Added args: ['rpn(expression)', 'stack = []', 'for item in expression:', "if item in ['+', '-', '*', '/']:", 'a = stack.pop()', 'b = stack.pop()', "if item == '+':", 'stack.append(a + b)', "elif item == '-':", 'stack.append(a - b)', "elif item == '*':", 'stack.append(a * b)', "elif item == '/':", 'stack.append(a / b)', 'else:', 'stack.append(item)', 'return stack.pop()']
Added args: ['rpn_calculator(expression)', 'stack = []', 'for i in expression:', "if i in ['+', '-', '*', '/']:", 'a = stack.pop()', 'b = stack.pop()', "if i == '+':", 'stack.append(a + b)', "elif i == '-':", 'stack.append(b - a)', "elif i == '*':", 'stack.append(a * b)', "elif i == '/':", 'stack.append(b / a)', 'else:', 'stack.append(i)', 'return stack.pop()']
Added args: ['rpn_calculator(expression)', 'stack = []', 'for i in expression:', "if i in ['+', '-', '*', '/']:", 'a = stack.pop()', 'b = stack.pop()', "if i == '+':", 'stack.append(a + b)', "elif i == '-':", 'stack.append(a - b)', "elif i == '*':", 'stack.append(a * b)', "elif i == '/':", 'stack.append(a / b)', 'else:', 'stack.append(i)', 'return stack.pop()']
Added args: ['rpn_calculator(expression)', 'stack = []', 'for element in expression:', "if element in ['+', '-', '*', '/']:", 'a = stack.pop()', 'b = stack.pop()', "if element == '+':", 'stack.append(a + b)', "elif element == '-':", 'stack.append(a - b)', "elif element == '*':", 'stack.append(a * b)', "elif element == '/':", 'stack.append(a / b)', 'else:', 'stack.append(element)', 'return stack.pop()']
Added args: ['rpn_calculator(expression)', 'stack = []', 'for element in expression:', 'if is_number(element):', 'stack.append(element)', 'else:', 'b = stack.pop()', 'a = stack.pop()', 'stack.append(apply_operator(element, a, b))', 'return stack.pop()']
Traceback (most recent call last):
  File "/Users/haldar/parsel/parsel.py", line 650, in <module>
    parsel(codegen, args.source_file, allow_autofill=args.allow_autofill, should_expand=args.allow_expand, debug=debug, add_name_and_args=args.add_name_and_args)
  File "/Users/haldar/parsel/parsel.py", line 617, in parsel
    _, defined_fns = get_graph(program)
  File "/Users/haldar/parsel/graph.py", line 42, in get_graph
    for cur_line in program:
TypeError: 'NoneType' object is not iterable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant