Skip to content

Don't visit if/else blocks that have unreachable limits #280

@amtep

Description

@amtep

This is mostly useful for script inside scripted effects and such. If an effect has

if = {
    limit = { $COUNT$ == 1 }
    ...
}

then there is no need to validate the rest of the block if COUNT is known to not be 1. Avoiding this validation not only saves time, it can suppress some useless warnings that would never be reached anyway, for example the use of scopes that are only set by callers that do pass COUNT = 1.

Implementation: the trigger validation functions would have to return a tri-bool (yes, no, maybe) to indicate whether a trigger is known true, known false, or indeterminate (the usual case). Probably the only cases we need to evaluate for truth are comparison of literal boolean, flag, and numerical values, and comparisons involving always. The logic of NOT, AND, OR, etc then has to be applied, and finally the if/else validation has to become more robust by among other things skipping the else branch if the if branch was always true.

Question: should there be a warning about always true / always false limits that are not in macros?

Places where this logic should apply:

  • if/elseif/else
  • trigger_if/trigger_elseif/trigger_else
  • switch
  • limits in every/ordered/random lists
  • any_ lists ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions