Giter Club home page Giter Club logo

luata-quickcheck's People

Contributors

jmid avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

algobardo

luata-quickcheck's Issues

__metatable is considered when resolving metamethods

It appears that the __metatable field of a metatable is considered when resolving metamethods. (At least in Lua 5.1, 5.2 and 5.3) it is the case that __metatable is only consulted when calling the getmetatable built-in from Lua code. It is not consulted when resolving actual metamethods. It exists only as a protection mechanism for metatables, and not for overloading them from the point of view of Lua.

This discrepancy causes luata to produce incorrect output for code using the __metatable metamethod.

local complexMt = { __metatable = "Complex number metatable protected" }

local function Complex(real,imag)
   local n = {real = real, imag = imag}
   setmetatable(n, complexMt)
   return n
end

function complexMt.__add(x,y)
   return Complex(x.real + y.real, x.imag + y.imag)
end

function complexMt:__tostring()
   return self.real .. "+" .. self.imag .. "i" 
end

z = Complex(1,0) + Complex(0,2)
print(z)

Expected output

$ lua mytest.lua
1+2i

License is missing

Hi!

I'm working on an editor plugin for Lua (atom-autocomplete-lua) and I would like to rewrite it using proper lattices. It would be really helpful to be able to use some of the code from this repo (especially the lexer and parser), but I can't do that because there is no license on this repo. Might you consider adding a LICENSE file? Maybe something permissive like the MIT license?

Uncertainty in function return types is lost

The analysis seems to be confident that c is going to have a number type instead of the actual nil type. The analysis correctly identifies that the second return value might have number type (based on my understanding of the question mark) ? { number: Top } however the analysis seems to give the wrong confidence to the type of b with ! { number: Top }

local function f(x)
        if x > 10 then
                return 1,2 
        else
                return 3
        end 
end

a,b=f(0)
c=type(b)
print(c)

Expected output:

$ lua mytest.lua
nil

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.