gopher-lua icon indicating copy to clipboard operation
gopher-lua copied to clipboard

bug

Open zizhilong opened this issue 5 years ago • 2 comments

  • [ ] GopherLua is a Lua5.1 implementation. You should be familiar with Lua programming language. Have you read Lua 5.1 reference manual carefully?
  • [ ] GopherLua is a Lua5.1 implementation. In Lua, to keep it simple, it is more important to remove functionalities rather than to add functionalities unlike other languages . If you are going to introduce some new cool functionalities into the GopherLua code base and the functionalities can be implemented by existing APIs, It should be implemented as a library.

Please answer the following before submitting your issue:

  1. What version of GopherLua are you using? : 0.0.0
  2. What version of Go are you using? : 1.14.1
  3. What operating system and processor architecture are you using? :windows
  4. What did you do? : =====main.lua==== require "bug" bug.conver("main") ============== =====bug.lua===== module(..., package.seeall) function conver(str) str = f() and str or str print(type(str)) end function f() return false end ================
  5. What did you expect to see? : string
  6. What did you see instead? : boolean

zizhilong avatar May 06 '20 11:05 zizhilong

function conver(str) str = f() and str or str print(type(str)) end function f() return false end conver("main")

zizhilong avatar May 07 '20 04:05 zizhilong

I've found out that if you don't reassign to the "str" variable it works as expected. Like this:

function f()
	return false
end
function conver(str)
	str2 = f() and str or str
	print(type(str2))
end
conver("main")

I guess there must be a bug in handling self-assigning expressions. Indeed weird!

epikur-io avatar Aug 23 '20 22:08 epikur-io