Skip to content
This repository was archived by the owner on Feb 11, 2025. It is now read-only.

Formatting invalid Lua overwrites the file #61

@ryanpcmcquen

Description

@ryanpcmcquen
local function combineTables(...)
	local combinedTable = {}
	local arg = {...}

	for k, v in pairs(arg) do
		if type(v) == 'table' then
			for tk, tv in pairs(v) do
				table.insert(combinedTable, tv)
			end
		end
	end

	return combinedTable
end

function table.assign(...)
	local newTable = {}
	local arg = {...}

	for k, v in pairs(arg) do
		if type(v) == 'table' then
			for tk, tv in pairs(v) do
				newTable[tk] = tv
			end
		end
	end

	return newTable
end

let one = { 'ctrl', 'alt' }
two = { 'shift' }

The let one above is syntactically incorrect in Lua, so running the formatter on it, overwrites the file with the error.

format_and_erase

It should probably log somewhere else and preserve the content.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions