News for hackers. Stuff that matters.
Re:Java record pattern matching in JDK 19 by danachow on Saturday May 14, 2022 @01:33PM (#31380303)
That’s not dataflow analysis. It looks like a cast similar to something like in C# ie: if (foo is string as foo) where the “as foo” scoped variable is implicit. It’s basically implicitly redefining the variable with limited scope. Type guards are a slick feature but it is just an expression match and some syntactic sugar. Even user defined type guards in typescript have to be explicitly declared as such.

This would be more an example of CFA.

  const a = “string”;
  if (typeof v === a)
Re:Java record pattern matching in JDK 19 by hn_throwaway_99 on Saturday May 14, 2022 @02:37PM (#31380941)
It's not just a simple cast, but I should have used the correct term which is "control flow analysis". It's not just redefining the variable, control flow analysis works in lots of different places besides just typeof checks, and is possible in many cases because TS is structurally typed, not nominally typed.