icerpc / slicec

The Slice compiler library
Apache License 2.0
13 stars 5 forks source link

Simplified Redefinition Check #584

Closed InsertCreativityHere closed 1 year ago

InsertCreativityHere commented 1 year ago

Currently we check for redefinitions in 2 ways:

This PR removes the 2nd method, and merges all the checks into a single check_for_redefinitions function. Additionally, we run this this before the rest of validation and exit early if there's a problem (right now we run these checks in the middle of validation).

Why? If there's a redefinition error, a validator might see the other definition, since only one of them will be visible in the AST. This can lead to spurious error messages about an element that's actually defined somewhere totally different. Our tests are small, so this doesn't happen in them, but could happen in a larger project with redefinitions in it.