Version: 0.329.0.188854
When typing into Studio’s script editor with the following source code, Studio either crashes, hangs indefinitely, or closes without warning. This happens every time I open this script in a new place in a Script, ModuleScript or LocalScript with Autocomplete enabled. I just patched Studio this evening and have never had any similar issues in previous patches.
The Big Bad Source Code (TM)
local util = require(game.ReplicatedStorage.Modules:WaitForChild("util"))
local Version = {}
Version.__index = Version
Version.names = {"major"; "minor"; "revision"; "build";}
Version.format = "v%d.%d.%d.%d"
function Version.new(v)
local self = setmetatable({
}, Version)
if type(v) == "table" then
if v[1] then
for i, name in pairs(self.names) do
self[name] = v[i] or 0
end
elseif v[self.names[1]] then
for i, name in pairs(self.names) do
self[name] = v[name] or 0
end
end
elseif type(v) == "string" then
-- Split the "a.b.c.d" format
local tab = util.split(v, ".")
for i, name in pairs(self.names) do
self[name] = tonumber(tab[i])
end
else
error(("Invalid version: %s"):format(v))
end
return Version
end
function Version:__tostring()
local t = {}
for i, name in pairs(self.names) do
t[i] = self[name]
end
return self.format:format(unpack(t))
end
function Version:__eq(other)
return self.major == other.major
and self.minor == other.minor
and self.revision == other.revision
and self.build == other.build
end
function Version:__lt(other)
for i, name in pairs(self.names) do
if self[name] >= other[name] then return false end
end
return true
end
Version.ZERO = Version.new("v0.0.0.0")
return Version
Repro steps:
- Create a new place with a new Script, ModuleScript or LocalScript anywhere within the place.
- Paste the
above script sourceone of the simpler script sources in my replies into the script editor. - Turn on Autocomplete if it isn’t on already.
- Attempt to type something into the script. Try typing
Version.blah = 123
on the line beforereturn Version
. - Studio crashes or closes without warning.
This is a really, really nasty bug…needless to say I’m keeping autocomplete off until this is fixed.
OK, so the bug is in fact Bad™, but it’s subtle and not likely to occur with normal script editing. See details below.