First line of code colored orange, removing specific elements undoes it


local Queue = {}

-- Create a new queue instance
function New(data : {}?, max_capacity : number?)
	return {
		_DATA = data or {},
		_MAX_CAPACITY = max_capacity or nil,
		Pop = Pop,
		Push = Push,
		Peek = Peek,
		Size = Size,
		IsEmpty = IsEmpty,
		IsFull = IsFull,
		Clear = Clear,
		GetIterator = GetIterator,
	}
end

-- Helper function to access data
local function data(Q)
	return Q._DATA
end

-- Helper function to access max capacity
local function max_capacity(Q)
	return Q._MAX_CAPACITY
end

-- Get the current size of the queue
function Size(Q) : number
	return #data(Q)
end

-- Remove and return the element at the front of the queue
function Pop(Q) : any?
	return table.remove(data(Q), 1) -- FIFO behavior
end

-- Add an element to the back of the queue
function Push(Q, v) : boolean
	if max_capacity(Q) and Size(Q) >= max_capacity(Q) then
		return false -- Queue is full
	end
	table.insert(data(Q), v)
	return true
end

-- View the element at the front without removing it
function Peek(Q) : any?
	return data(Q)[1] -- FIFO behavior
end

-- Check if the queue is empty
function IsEmpty(Q) : boolean
	return Size(Q) == 0
end

-- Check if the queue is full
function IsFull(Q) : boolean
	return max_capacity(Q) and Size(Q) >= max_capacity(Q)
end

-- Clear the queue
function Clear(Q)
	Q._DATA = {}
end

-- Get an iterator for the queue
function GetIterator(Q)
	local index = 0
	local size = Size(Q)
	return function()
		index = index + 1
		if index <= size then
			return Q._DATA[index]
		end
	end
end

return New

Removing certain elements from the code fixes it. For example, removing : boolean from IsFull. Also, moving IsFull to a different position in the script also fixes it, without needing to remove : boolean

image

I have all beta-features enabled besides the following:

  • Next Gen Explorer
  • Next Gen Studio Preview
  • Avatar Auto-Setup Beta

Expected behavior

It shouldn’t be orange; there’s no issue.

2 Likes

This seems similar to the mostly red line you sometimes get when there is a typechecking error.

I’ve run into issues with the new type-solver having issues with and / or operators used on comparison statements, so it is possible that it is related to this issue.

Also, in this code sample, max_capacity could be nil, which could be leading to the typechecking issue.

Not the issue. Setting it to 0 still errors it. In fact, getting rid of the whole New function, doesn’t change anything.

Thanks for the report! I filed a ticket in our internal database.

Hi, @ExercitusMortem,

Thank you for filing this. Can you please verify that the issue still happens even with turining off the new Type Solver Beta?

Thank you!

Currently, I’m not getting the bug anymore at all (both with new type solver enabled and disabled).

Thank you, let’s keep an eye on this and if it doesn’t repro any more we can close it: I suspect that the new solver was updated and it fixed this problem.

It’s back now. Newtype solver is enabled.

Hi @ExercitusMortem,

Thanks for getting back to me on this.
Can you please look at the Script Analysis widget and let us know what the error is? Then, can you please disable the solver beta to see if it causes this issue?

Thank you!


Here you go, this is in another script.

With the new type solver disabled, the error disappeared.

I can confirm that this happens to me as well.

I can confirm this also happens to me, with the beta type solver enabled

I get this too, really annoying & obnoxious

Thank you! I’m forwarding this to the team working on the new Type Solver.