Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Gamesparks plugin will not load when using lua strict
Started by jack95 Apr 01 2018 09:13 AM

5 replies to this topic
[TOPIC CONTROLS]
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

jack95

[GLOBAL: userInfoPane.html]
jack95
  • Contributor

  • 189 posts
  • Corona SDK

This will prevent the gamespark plugin from loading:

local mt = getmetatable(_G)
if mt == nil then
  mt = {}
  setmetatable(_G, mt)
end


__STRICT = true
mt.__declared = {}


mt.__newindex = function (t, n, v)
  if __STRICT and not mt.__declared[n] then
    local w = debug.getinfo(2, "S").what
    if w ~= "main" and w ~= "C" then
      error("assign to undeclared variable '"..n.."'", 2)
    end
    mt.__declared[n] = true
  end
  rawset(t, n, v)
end

local GS = require("plugin.gamesparks")

 

 

I think this is a bug?



[TOPIC: post.html]
#2

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 24,853 posts
  • Corona Staff

You should reach out to GameSparks. They maintain their own plugin.  

 

Rob



[TOPIC: post.html]
#3

jack95

[GLOBAL: userInfoPane.html]
jack95
  • Contributor

  • 189 posts
  • Corona SDK

This might be a problem with the plugin, but debugging has revealed a problem with the way the Library generator works (internally opaque).

 

See the attachment. There is no gamesparks specific content, just Corona and pure lua, with some paths that are gamesparks.

 

Attempting to load the plugin with "strict.lua" trying to catch global leaks, any require into the plugin folder results in a failed plugin load.

 

This is a Corona specific issue. If this is intentional, it seems wrong and will prevent a classic type of static check (prevent global scope pollution).

 

Attached Files

  • Attached File  lua.zip   9.88KB   2 downloads


[TOPIC: post.html]
#4

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 24,853 posts
  • Corona Staff

Can you submit your .zip file to us as a bug report? It needs a config.lua added, but you can use the "Report a Bug" link at the top of this page and write up a good description of the issue and attach the zip file.

 

Thanks

Rob



[TOPIC: post.html]
#5

roaminggamer

[GLOBAL: userInfoPane.html]
roaminggamer
  • Corona Geek

  • 7,281 posts
  • Corona SDK

@jack,

 

I'm not clear why you're doing this.  Are you simply trying to verify that your code is not creating unnecessary global as as a pre-release validation step or is this something you intend to have enabled in your release.

 

If the latter, I think you might be safer living with some unwanted global creation versus a crash. 

 

Just some input. 



[TOPIC: post.html]
#6

jack95

[GLOBAL: userInfoPane.html]
jack95
  • Contributor

  • 189 posts
  • Corona SDK

@roaminggamer

 

The strict.lua is my first go-to tool when checking someone's lua code.

In this case, it came up when trying to look into the gamespark library, which was failing in my project (where this is also enabled) and then the test harness for their Corona library project and eventually the Corona library template project.

 

The crash is preventing me from understanding what a third party plugin is doing because Corona's plugin loading system has an internal leak. This is not a production stopping issue, but it's not trivial for my very large project.




[topic_controls]
[/topic_controls]