Closed rillig closed 2 years ago
This is unfortunately a complicated case. The return type of that function isn't actually nil | table
, it's void | table
.
The problem is void
is the absence of a value i.e. the empty set. When you put it in a union, it makes no contribution: https://github.com/Benjamin-Dobell/IntelliJ-Luanalysis/issues/45
I'd have to change the representation of void
at a pretty low level to make this work.
In this case if you actually want nil | table
, then you ought to be able to change the return statement to return nil
rather than nothing.
Ah, that's tricky indeed. Feel free to close it as a duplicate then.
Environment
Preferences
What are the steps to reproduce this issue?
What happens?
The inferred return type of the function is
table
.What were you expecting to happen?
The inferred return type of the function is
nil | table
or() | table
. There is a warning that _The function 'inconsistentreturn' sometimes returns a value. (Don't know whether that would be practical in general though.)