Comments (10)
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.
Also, is this compiled from master
or the official 1.2.1
release?
from intellij-luanalysis.
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.
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.
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.
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:
- Provide an explicit class name e.g.
---@class StringUtilities
. - 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.
OK, I see, makes sense. Good luck for the proper fix then.
Thanks for the tips!
from intellij-luanalysis.
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.
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:
In a standard intellij project, no such error anymore, although something else (that may be expected, but a bit strange?):
from intellij-luanalysis.
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)
- nil checks are not context-aware
- Hello, Is it possible to type a global value with Luanalysis ?
- Top and Bottom Types Distinct from "any" HOT 5
- Unnecessary '0 results are excess arguments' warning HOT 1
- Invalid type mismatch error is given when passing along optional `shape` from one function to another HOT 3
- Type mismatch error when assigning subclasses to an array of superclass HOT 2
- java.lang.NullPointerException HOT 2
- `table<>` definitions with incorrect Type Mismatch errors HOT 1
- Add std defs for LuaJIT
- Allow custom function definitions in table
- Support multi-line text in @field and @param comments
- There seems to be no way to define a non-nil generic return value for a function
- Wrong return type for os.execute
- error HOT 1
- Returned anonymous function is not type-checked HOT 1
- Luanalysis doesn't seem to understand manual nil check
- Executing the Rename action on some files causes severe freeze
- Lua code formatting moves some end-of-line comments to a new line
- Upgrade EmmyLua version. HOT 1
- Add support for multiline alias
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from intellij-luanalysis.