Formatting "Error" With Strings and Instance Variables

Reproduction Steps

Type in something exactly like;

local TableOfVariables = {
	["Name"] = "Part Name"
}
local Part:BasePart = Instance.new("Part")
for i:string,v:any in pairs(TableOfVariables) do
	Part[i] = v
end

Expected Behavior

The formatting should be correct without it displaying a red “malformed” underline.

Actual Behavior

There is a red “malformed” underline displayed under the “malformed” text, stating that Expected type table, got 'BasePart' instead when the variable is defined.

Images

image
image

Issue Area: Studio
Issue Type: Other
Impact: Low
Frequency: Constantly
Date Last Experienced: 2022-07-25 00:07:00 (-05:00)

I cannot reproduce the issue. Try retyping the code to see if there’s any difference.

If you are in strict mode (you should specify), it does show the underline.

If you copy and paste my example code and it should show up as shown in the image. It only works if you define a variable like this;

local Part:BasePart = Instance.new("Part")
Part["Name"] = "Part Name"

The lack of definition doesn’t have any issues

local Part = Instance.new("Part")
Part["Name"] = "Part Name"

I edited it to state above

I had same issue and its some typchecking trash. So you should report this to roblox.

I made this post to report to Roblox, but I also wanted to know if anyone else is getting this issue as it is bothering me since I like to make sure my code has no errors.

This error will only show up in strict mode for me, are you using strict mode?

I am not using strict mode. It works while defining variables instead of leaving them as is

It seems like the error only appears within strict mode:
image
image

Odd. It happens both on and off of strict mode. The script I am using doesn’t have strict mode on at all. Here is what it shows for me.
image
How is it different for different clients?

It’s such a minor thing that doesn’t affect games, but it’s annoying for sure. Happens on both of my PCs using Windows 11 and Windows 10 respectively.

It might happen because the name is Name? Try changing it this is guessing work.

It does it with any instance and variable
image
There is no workaround apart from not defining the variable (which annoys me as I also use Unity and C#)
image

Is your computer always strict mode?

No, it is not always in strict mode. It happens on all devices I try it on, even ones with an unaltered Roblox Studio.

Weird, it sometimes happens and sometimes doesn’t.

This doesn’t error have the error;
image

But this does;
image
image

It may be due to how i in the for loop could be any string and treats assigning the strings like a table variable instead of a property. That’s the best I could explain it.

Can you run that script basically…?

Can’t repro without strict mode, but I get the red “malformed” underline when using strict mode. No errors in output.

Images

image
image

That is very weird as I never use --!strict unless I really have to. I have no idea how it occurs for some but not all. I’ll definitely look into things on my end and see if that may be my issue or not.

In case this helps, here are my script settings outside of the colour customization:

Also, from what I know, there are no errors in the output. It’s only an error in the Script Analysis tab (In which usually doesn’t have any problems when running scripts)

Yes, the scripts can be run normally without any issues. It’s only a minor studio inconsistency :sweat_smile:

https://github.com/Roblox/luau/issues/586 expected behavior

Thanks for the report! We’ll follow up when we have an update for you.

2 Likes