Luau Recap: September & October 2022

Luau is our new language that you can read more about at https://luau-lang.org.

Semantic subtyping

One of the most important goals for Luau is to avoid false positives, that is cases where Script Analysis reports a type error, but in fact, the code is correct. This is very frustrating, especially for beginners. Spending time chasing down a gnarly type error only to discover that it was the type system that’s wrong is nobody’s idea of fun!

We are pleased to announce that a major component of minimizing false positives has landed, semantic subtyping, which removes a class of false positives caused by failures of subtyping. For example, in the program

  local x : CFrame = CFrame.new()
  local y : Vector3 | CFrame
  if (math.random()) then
    y = CFrame.new()
  else
    y = Vector3.new()
  end
  local z : Vector3 | CFrame = x * y -- Type Error!

an error is reported, even though there is no problem at runtime. This is because CFrame ’s multiplication has two overloads:

    ((CFrame, CFrame) -> CFrame)
  & ((CFrame, Vector3) -> Vector3)

The current syntax-driven algorithm for subtyping is not sophisticated enough to realize that this is a subtype of the desired type:

  (CFrame, Vector3 | CFrame) -> (Vector3 | CFrame)

Our new algorithm is driven by the semantics of subtyping, not the syntax of types, and eliminates this class of false positives.

If you want to know more about semantic subtyping in Luau, check out our technical blog post on the subject.

Other analysis improvements

  • Improve stringification of function types.
  • Improve parse error warnings in the case of missing tokens after a comma.
  • Improve typechecking of expressions involving variadics such as { ... }.
  • Make sure modules don’t return unbound generic types.
  • Improve cycle detection in stringifying types.
  • Improve type inference of combinations of intersections and generic functions.
  • Improve typechecking when calling a function that returns a variadic e.g. () -> (number...).
  • Improve typechecking when passing a function expression as a parameter to a function.
  • Improve error reporting locations.
  • Remove some sources of memory corruption and crashes.

Other runtime and debugger improvements

  • Improve performance of accessing debug info.
  • Improve performance of getmetatable and setmetatable.
  • Remove a source of freezes in the debugger.
  • Improve GC accuracy and performance.

Thanks

Thanks for all the contributions!

111 Likes

This topic was automatically opened after 10 minutes.

With how fast this language progresses, I’m always looking forward to these recaps to see if there’s any new features I might’ve missed in between. We all appreciate what you guys are doing for us. Keep up the good work!

17 Likes

I wonder what big stuff will be implemented this month. Keep it up Roblox!

10 Likes

This is actually an incredible performance boost for the OOP idiom, as benchmarks are now showing the pattern performing 7 microseconds faster than using a table without metatables! (Beforehand, setting the metatable slowed it down a lot).

However, I still feel like there needs to be some facelift to the paradigm as it’s unorthodox to force developers to work with such low-level metaprogramming just to mimic object-like programming. I hope we get some proper class syntax in the future!

14 Likes

The one thing that’s still personally crippling about typechecking is its inability to typecheck non-static require paths. As a developer who bases a large number of projects with single-script architecture I always do not have static require paths from the DataModel tree.

I do hope this can be touched on some day. Not sure if there’s some Feature Request or RFC out there for it but it would be incredibly helpful to have and encourage me to actually do full strict typechecking in my code instead of half baked or opting not to use typechecking at all.

16 Likes

That is pretty cool! Keep on going Roblox!

I’m excited to see what more will come out soon.

10 Likes

Is string interpolation still a feature that’s being worked on/on the roadmap? I love these new features but string interpolation is something I’ve been waiting (anxiously) for.

4 Likes

Actually, it seems that it’s already in studio but it doesn’t highlight properly:
image

11 Likes

Oooooh that’s awesome, I tried it as well but it told me syntax error so I thought it was something that was abandoned. Thanks for letting me know!!

6 Likes

Actually correction, I realized I enabled LuauInterpolatedStringBaseSupport at some point with mod manager without realizing it, so unless you enable that fast flag, it might not work.

11 Likes

Finally, I was looking forward into this kind of feature for a long time. It looks like JavaScript syntax but without the unnecessary dollar sign.

5 Likes

This is going to be VERY useful, thank you!

3 Likes

Yes, we would have liked to have it available already, but we still need to handle a few remaining issues with it.

5 Likes

i feel like luau should now get a purpose outside of roblox, it can run outside of roblox, wb now like being compatible with luarocks and luvit, going on the web by making openresty port? seems like a good idea to me

its a nice lang capable to replace the entire lua, so why not

3 Likes

I wonder why these weren’t FASTCALL functions to begin with, regardless, speed

3 Likes

You’re joking… been waiting for this forever.

3 Likes

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.