Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Stack overflow while attempting to resolve function return value #3246

Closed
@Cooldude2606

Description

How are you using the lua-language-server?

Visual Studio Code Extension (sumneko.lua)

Which OS are you using?

Windows

What is the issue affecting?

Type Checking

Expected Behaviour

It is expected that the return value (callback) is resolved to Callback<string> which is expanded to fun(): Success, string where Success is fun(): Success (returns itself) without causing a stack overflow.

Actual Behaviour

A stack overflow occurs and the return value has an unknown type.

Reproduction steps

  1. Copy the following code into a lua file.
--- @alias Success fun(): Success
--- @alias Callback<T> fun(): Success, T
--- @return Success
local function success()
 return success
end
--- @generic T
--- @param callback Callback<T>
--- @return Callback<T>
local function make_callback(callback)
 return callback
end
local callback = make_callback(function()
 return success, ""
end)
  1. No special vscode settings or luarc file is required.
  2. Upon workspace reload or diagonistics, a stack overflow immediately occurs. Visible via view->output->Lua

Additional Notes

This is an abstract minimum reproduction of the issue. My full use case has multiple self returning functions used to indicate different statuses, and the make_callback function would be a method on a class instance to which the callbacks are registered to.

Log File

stack_overflow.log

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

        AltStyle によって変換されたページ (->オリジナル) /