Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix redeclaring i #523

Merged
merged 3 commits into from
May 31, 2022
Merged

Fix redeclaring i #523

merged 3 commits into from
May 31, 2022

Conversation

Koeng101
Copy link
Contributor

When running teal in gopher-lua (https://github.com/yuin/gopher-lua), types get checked by the system, and the single line i, node.decltype = i, decltype caused a complete failure to run teal. When replaced with the equivalent node.decltype = decltype, the system runs just fine.

These should be functionally equivalent. Nothing else is changed and it does not appear to change any tests.

@hishamhm hishamhm merged commit ce5c741 into teal-language:master May 31, 2022
@tooolbox
Copy link

tooolbox commented Jun 6, 2022

@tooolbox
Copy link

tooolbox commented Jun 7, 2022

@Koeng101 I'm curious what you ended up doing for the load vs. loadstring bit, because I saw you threw in a fix for that and then took it out. I'm using compat52.lua and its dependencies to run Teal in Gopher-Lua, but it's not ideal since it calls string.dump which blows up, so I had to modify the lib.

@Koeng101
Copy link
Contributor Author

Koeng101 commented Jun 7, 2022

@tooolbox I added in a check into tl.tl that if it detected version 5.1, it would use load instead. The link is here - 4406b73

kinda dumb simple:

      if _VERSION == "Lua 5.1" then
         chunk = loadstring(code)
         err = "5.1 error"
      else
         chunk, err = load(code, "@" .. found_filename, "t")
      end

I threw it out because I thought it might not be idiomatic or well made lua code (you also need to add that check into the other occurrence of load()) . For my application, I actually want to use the lua conversion, so I just do this:

err = L.DoString(fmt.Sprintf("return tl.gen([========[%s]========])", tealCode))
        if err != nil {
                return "", err
        }
        parsedLua := L.Get(1)

It outputs a lua string, which I save, and then I just run the outputted lua. Kinda hacky, but is what I wanted to do in the first place.

I had no idea that yuin/gopher-lua#314 was there, or else I probably would have been a lot less inclined to figure out something that worked.

@tooolbox
Copy link

tooolbox commented Jun 8, 2022

Gotcha, so you're loading the Lua string yourself. Okay, thanks for sharing that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants