NightrainsRbx / RobloxLsp

Roblox Luau Language Server based on Lua by sumneko.
https://devforum.roblox.com/t/roblox-lsp-full-intellisense-for-roblox-and-luau/717745
MIT License
211 stars 49 forks source link

onTypeFormatting failure - attempt to perform arithmetic on a nil value (local 'pos') #230

Closed unix-system closed 10 months ago

unix-system commented 11 months ago

Reproduction Steps

Unknown. Seems to happen when there isn't valid formatting on a function's end statement. It tries doing a glob match for the pattern: ^[ \t]*() but does not validate if this returns anything.

Stack Trace

script\core\type-formatting.lua:19: attempt to perform arithmetic on a nil value (local 'pos')
stack traceback:
    script\core\type-formatting.lua:41: in upvalue 'checkSplitOneLine'
    script\core\type-formatting.lua:80: in function 'core.type-formatting'
    script\provider\provider.lua:955: in function <script\provider\provider.lua:945>
    [C]: in function 'xpcall'
    script\proto\proto.lua:143: in function <script\proto\proto.lua:122>
[Error - 11:11:30 AM] Request textDocument/onTypeFormatting failed.
  Message: [11:11:30.910][error][#0:script\core\type-formatting.lua:41]: script\core\type-formatting.lua:19: attempt to perform arithmetic on a nil value (local 'pos')
stack traceback:
    script\core\type-formatting.lua:41: in upvalue 'checkSplitOneLine'
    script\core\type-formatting.lua:80: in function 'core.type-formatting'
    script\provider\provider.lua:955: in function <script\provider\provider.lua:945>
    [C]: in function 'xpcall'
    script\proto\proto.lua:143: in function <script\proto\proto.lua:122>

  Code: -32603