Skip to content

Commit

Permalink
parser: Don't forbid overriding builtins
Browse files Browse the repository at this point in the history
Banning variables named as builtins is undesirable for forward
compatibility, as any new name might invalidate programs that use that
name.

Fixes issue #29.

Signed-off-by: Petr Machata <[email protected]>
  • Loading branch information
pmachata committed Dec 19, 2017
1 parent 0b89d97 commit 6fec539
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions libzwerg/parser.yy
Original file line number Diff line number Diff line change
Expand Up @@ -194,15 +194,11 @@
{
std::unique_ptr <tree> ret;
for (auto const &s: *ids)
if (builtins.find (s) == nullptr)
{
std::unique_ptr <tree> t {tree::create_str <tree_type::BIND> (s)};
ret = tree::create_cat <tree_type::CAT>
(std::move (ret), std::move (t));
}
else
throw std::runtime_error
(std::string ("Can't rebind a builtin: `") + s + "'");
{
std::unique_ptr <tree> t {tree::create_str <tree_type::BIND> (s)};
ret = tree::create_cat <tree_type::CAT>
(std::move (ret), std::move (t));
}

return ret;
}
Expand Down

0 comments on commit 6fec539

Please sign in to comment.