guppylang icon indicating copy to clipboard operation
guppylang copied to clipboard

Py keyword takes precedence over identifier with the same name

Open mark-koch opened this issue 1 year ago • 2 comments

What happens if I write

@guppy
def f() -> int:
    py = lambda x: x+1
    return py(2)

?

Originally posted by @aborgna-q in https://github.com/CQCL/guppylang/pull/515#discussion_r1782506340

mark-koch avatar Oct 01 '24 14:10 mark-koch

In see two options:

  • Turn py into an actual function and use a CustomCallChecker
  • Disallow naming variables py since it's a "keyword"

mark-koch avatar Oct 01 '24 14:10 mark-koch

I'd say option 1 is the more pythonic. There are no function keywords in python3. From a user perspective, if you can shadow print you should be able to do the same with py.

aborgna-q avatar Oct 01 '24 14:10 aborgna-q