Skip to content

The flow analysis specification seems to ignore types of interest in a try block #4328

@eernstg

Description

@eernstg

We have the following rule:

  • try catch: If N is a try/catch statement of the form try B alternatives then:
    • Let before(B) = before(N)
    • For each catch block on Ti Si in alternatives:
      • Let before(Si) = conservativeJoin(before(N), assignedIn(B), capturedIn(B))
    • Let after(N) = join(after(B), after(C0), ..., after(Ck))

The static analysis function conservativeJoin receives information about variables which are assigned in B and variables which are write-captured in B, both as raw occurrences with no considerations about the control flow, but it doesn't receive any information about types of interest.

This seems to imply that no types of interest established by code in the try block are taken into account during the analysis of the catch clauses, or even the code after the try-catch statement.

A similar situation seems to exist for the try-finally statement.

However, the implemented behavior seems to be different. It does take such types of interest into account, at least in some cases:

main() {
  num i = 1 as dynamic;
  try {
    i as int;
  } catch (_) {}
  i = 1;
  i.isEven; // OK.
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    flow-analysisDiscussions about possible future improvements to flow analysisquestionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions