Can insert unrelated types into arrays

Repro steps:

  • This script with the New Luau Type Solver beta (not sure if it’s required):
--!strict

local a: { Part } = {}
local s: string = "hi"

table.insert(a, s)

Expected behavior:
A warning on the table.insert line

Actual behavior:
No warning

1 Like

Thanks for the report! We’re already investigating this, as it happens. We hope the fix will be ready soon.

1 Like

This appears to have been fixed in some update in the intervening time, however maybe the generated warning could be a little better:

Hovering over table.insert’s 2-parameter overload:

Hovering over the arguments instead of table.insert:

Hovering over table.insert’s 3-parameter overload

With:

local a: { number } = {}
local s: string = "hi"

table.insert(a, s)
table.insert(a, 1, s)

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