Skip to content

Commit

Permalink
[oil-language] Revert the dynamic check for var/const.
Browse files Browse the repository at this point in the history
It messed up the loop use case.
  • Loading branch information
Andy Chu committed Jan 11, 2021
1 parent 5a2145f commit 6631385
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
15 changes: 6 additions & 9 deletions core/state.py
Expand Up @@ -1276,15 +1276,12 @@ def _CheckOilKeyword(self, keyword_id, name, cell):
definition and mutation will help translate the Oil subset of OSH to static
languages.
"""
if cell is not None and keyword_id in (Id.KW_Var, Id.KW_Const):
# This dynamic check is for 'local' before 'var', or 'readonly before
# 'const', etc.
#
# Another option: REMOVE assignment builtins from 'proc'. You can only
# use keywords.

# TODO: location
e_die('%r has already been declared', name)
# This dynamic check can prevent 'local' before 'var', or 'readonly before
# 'const', etc. But it also prevents 'var' in a loop, which we don't want.
# TODO: Possibly disable local/readonly/declare inside 'proc'.

# if cell is not None and keyword_id in (Id.KW_Var, Id.KW_Const):
# e_die('%r has already been declared', name)

# TODO: Also do this at parse time. We have some name resolution in
# ctx_Declarations.
Expand Down
3 changes: 2 additions & 1 deletion spec/oil-assign.test.sh
Expand Up @@ -278,7 +278,8 @@ run --assign-status :st eval 'readonly-const' || true
echo status=$st

## STDOUT:
status=1
x=2
status=0
status=1
## END

Expand Down

0 comments on commit 6631385

Please sign in to comment.