Studio crashes WITHOUT autorecovery file on second encounter of typechecker error with Debug on Unhandled Exceptions on server run test

I was working on a module for the past couple of hours, and I do regular sanity checks by having a script require() that module, in order to check if I forgot some syntax somewhere. I had the debug errors on unhandled exceptions turned on (from earlier debugging of another module), which is useless for fake luau type checker errors, but I forgot to turn it off.

I write my modules with nonstrict mode on, and I use type notation to have the autocomplete work. As I was writing one of my functions, I used studio RUN mode to test it (server run, no client, not playtest), and it ran into a fake typechecker error, which froze the test because “debug on unhandled exceptions” was on. The error was something like

function a(): (any, any)?
end
--the question mark denotes that the return type could possibly be nil
-- <type>? is legal
-- however, having a multi return (type, type) wrapped in parentheses with a ? after breaks the type checker

This typechecker error is probably unrelated to the crash, I’m pretty sure any typechecker error will crash studio if you follow the repro steps below.
This INITIAL error did not crash studio. I stop the run, got rid of the question mark (therefore fixing the error), and tried to run again. This should have been a working run, but for some reason it crashed studio, and there was no autorecovery file to be found after reopening studio.

I was frustrated from losing some progress so I tried to reproduce the recovery-less crash and was able to do so pretty easily. I isolated the culprit down to just a few factors:

WARNING: Save and close any instances of studio before trying to reproduce. Open a new empty baseplate

  1. In Script Tab on topbar, click “On Unhandled Exceptions” in the Debug Errors section
  2. In Home tab on topbar, set the “Play” option to “Run”
  3. Create a script anywhere that just requires a module
require(game.ServerScriptService.ModuleScript)
  1. In the module put this (or something else that will cause a type checker error)
local module = {}
function module.fn(a) :(number, number)?
	return 1,1
end
return module
  1. Click Run. Execution should stop and debugger will trigger.
    Debugger should say: “ServerScriptService.ModuleScript:2: Expected identifier when parsing expression, got ‘?’”
    Click Stop.
  2. Click Run again. Studio will crash without warning and no autorecovery file will be made. This crash will ALWAYS HAPPEN on the second Run, even if you erase everything in the modulescript and script. The only way to prevent a crash on the second Run is to delete the scripts. The first Run seems to corrupt the state of the scripts and the second Run breaks studio as it tries to process the scripts, thus no autorecovery file is made since it didn’t get to the usual savepoint.

Note: This works with RUN only, Play does not crash.
Edit: If it doesn’t crash on the 2nd run, try running a couple more times.
crasher.rbxl (54.6 KB)

Expected behavior

it shouldnt crash and i shouldnt lose my hours of progress man

A private message is associated with this bug report