Giter Club home page Giter Club logo

Comments (10)

Benjamin-Dobell avatar Benjamin-Dobell commented on September 15, 2024

I'm unable to reproduce this. It's possible there was an error somewhere and Luanalysis is in a bad state.

First, if you could check for any error stacktraces that'd be great. Down the bottom right of IntelliJ there may a red exclamation mark icon (notifications). If there's something in there you can share that'd be great.

Otherwise, can you reproduce this after File -> Invalidate Caches / Restart... -> Invalidate and Restart?

from intellij-luanalysis.

Benjamin-Dobell avatar Benjamin-Dobell commented on September 15, 2024

Also, is this compiled from master or the official 1.2.1 release?

from intellij-luanalysis.

adriweb avatar adriweb commented on September 15, 2024

Unfortunately, nothing in the event log / notifications, and same after invalidate&restart.
This is the official 1.2.1 release.

I doubt it helps more since you probably knew already, but the inspections' name are "Assign type" for point 2 and "Return type" for point 3, in Lua > Lint > Type Safety settings.

from intellij-luanalysis.

Benjamin-Dobell avatar Benjamin-Dobell commented on September 15, 2024

Think I found the bug.

I'm guessing this is in a file called utilities.lua and you have other files that are also called utilities.lua?

from intellij-luanalysis.

adriweb avatar adriweb commented on September 15, 2024

Oh, that's true - this project in Intellij is a "meta-project" (not sure if that's the official name) and has all the other projects loaded too... Which makes all cross-dependencies work magically, but I guess creates this problem now.
Good catch !

What do you think a solution would be?

from intellij-luanalysis.

Benjamin-Dobell avatar Benjamin-Dobell commented on September 15, 2024

Basically internally tables without an explicit type are given names like <filename>@(<offset>)table.

This is behaviour that originated in EmmyLua though, and it seems the file name is used in other circumstances too. So I'll need to properly go through and understand the repercussions before fixing it. It's definitely a bug that needs to be corrected in Luanalysis though.

For now you can work around it one of two ways:

  1. Provide an explicit class name e.g. ---@class StringUtilities.
  2. Or, if you really don't want to do that and are up for a very hacky solution. You can ensure your two local utilities = {} declarations don't share the same offset in their file (comments, whitespace etc.)

from intellij-luanalysis.

adriweb avatar adriweb commented on September 15, 2024

OK, I see, makes sense. Good luck for the proper fix then.
Thanks for the tips!

from intellij-luanalysis.

adriweb avatar adriweb commented on September 15, 2024

Is that also related to the following issue somehow?

In the plugin settings, "Lua Additional Sources root" has project "Common"

-- in Project A, in foobar.lua:
local Constants = require("Common.Constants")
print(Constants.FOO)

-- in Project Common, in Constants.lua:
return {
  FOO = true,
  BAR = 42
}

OK: Ctrl-Clicking on the Common.Constants inside the require works fine and brings me to the out-of-project "Constants.lua" file.
FAIL: there's squiggly lines in the Constants.FOO print usage, and the error is: No such member 'FOO' found on type 'table'. Similarly, no autocompletion for Constants.***.

Everything is OK again if I just add ---@type table at the top of Constants.lua.

I should note that this is new behaviour, before I updated today, there were no such "issues".

from intellij-luanalysis.

adriweb avatar adriweb commented on September 15, 2024

In fact, it's also probably linked to all kinds of errors I'm getting in this meta-projects project.

A tiny repro:

local function foobar()
  local test = { 1, 2, 3 }
  test[2] = 0
end

In the meta-project intellij project:
image

In a standard intellij project, no such error anymore, although something else (that may be expected, but a bit strange?):
image

from intellij-luanalysis.

Benjamin-Dobell avatar Benjamin-Dobell commented on September 15, 2024

Should be fixed in v1.2.2. Currently being reviewed by Jetbrains, but you can grab it from Github in the meantime.

from intellij-luanalysis.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.