Fix bug in attribution

- Self-reference in constant def (e.g., CONST A A) was causing stack
  blowout instead of throwing an error

- Added unit test