naitoh / py2rb

A code translator using AST from Python to Ruby.
MIT License
134 stars 17 forks source link

Upper case variable names in functions causes ruby error: dynamic constant assignment #9

Open jayvdb opened 3 years ago

jayvdb commented 3 years ago

Python

def f():
  CODES = {"KEY": 1}
  return CODES

becomes

def f()
  CODES = {"KEY" => 1}
end

Ruby complains that CODES is a constant, when it was a local variable in Python.

foo.rb:2: dynamic constant assignment
  CODES = {"KEY" => 1}