Calling getmetatable on a table union causes type checker to crash

Calling getmetatable on this unioned table type from a function:

type Table = { 
	property: any,
	[any]: any?
} | {}

causes Studio to crash only when:

  • the new Lua script analysis beta feature is on,
  • the Table type is referenced as an argument to a function,
  • getmetatable is called on that argument,
  • the two table types are unioned in that specific order,
  • the property token is 3 characters or larger,
  • and the function token is 3 characters or larger

The crash may not occur immediately when pasted. Undoing and repasting the code will eventually cause studio to crash, however. The minimum amount of repasting I had to do was only five times, and that only happened once in my own testing.

I just discovered this bug today.


  1. Create a new baseplate place,
  2. Paste this code into any Luau source container:
type T = {
	___: any,
	[any]: any
} | {}

local function ___(t: T)
  1. Studio should crash immediately, and if not, undo the operation and repeat step 2.


OS: Windows 10
CPU: AMD Ryzen 7 1700 Eight-Core Processor
Memory: 16.0 GB
GPU: Radeon RX 550

Crash Dump

1 Like

This was a good report! I have a fix for this going in next week.

FYI, it does not require 3 characters or more for those name. It also doesn’t specifically require getmetatable either. However, you are correct in that it does require that there is:

  • {x: number, [any]: any} | {} - in this order.
  • you have to have a function taking a property that doesn’t exist in either member of the union.

Which means this is also another repro:

type T = {x: number, [any]: any} | {}
local t: T

function f(a)
  a.y = 1

1 Like

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