septract/starling-tool

Improve 'not in environment' errors

Closed this issue · 0 comments

(Thanks to @bensimner for reminding me to add this!)

Currently, if the modeller sees a variable that is not in the correct scope for a given expression, it says

variable 'x' not in environment

This occurs for various reasons:

  • The variable doesn't exist at all (in shared or thread)
  • The variable is shared but must be in thread
  • The variable is thread but must be in shared

These three should be distinguished in the error message, i.e.

  • unknown variable 'x'
  • cannot use shared variable 'x' in a thread-local context, consider taking a thread-local copy
  • cannot use thread variable 'x' in a shared context, consider taking a shared copy

This will need some additional plumbing in the modeller to propagate the expected class of variable. My gut feeling is that the environment passed into modelXYZExpr should instead be a function specific to the intended class of variable, which looks up in the correct environment, then looks up in the other one, then spits out the appropriate error.

This is non-critical but has tripped lots of users up now, so it could do with being fixed.