Giter Site home page Giter Site logo

Comments (5)

technomancy avatar technomancy commented on September 15, 2024

The error you're seeing is coming from the Fennel compiler; it's saying that you're trying to reference a global that doesn't exist. In fact, interleave is not a global; the only place it's defined in the Luakit source is inside the label_styles table here: https://github.com/luakit/luakit/blob/develop/lib/select_wm.lua#L67

But when you run the Lua, it turns out the Lua is able to resolve it somehow. They are probably using a metatable on the _G globals table to magically resolve it at runtime. This is a weird technique that ends up causing a lot of problems and is best avoided, but in this case it's outside your control to fix.

The simplest way to work around this is to just turn off global checking altogether, but that would make it so the compiler couldn't catch typos, so I don't recommend this. If you try replacing interleave with _G.interleave you can bypass the strict global checks just for this one call but still benefit from its checks in the rest of your code; I think that's probably the best workaround for you.

But the best fix is for Luakit to stop doing this provide the function in a module for you to use normally.

Unrelatedly, the last line would be better as this instead: (fn select.label_maker [] (_G.interleave "arst" "neio"))

from fennel.

fosskers avatar fosskers commented on September 15, 2024

Thank you! Yes I suspected they were up to some internal funny business.
By prefixing interleave by _G the browser actually starts now, but the resetting of label_maker fails (without crashing the browser). I'm told:

Lua error: attempt to index global '_G' (a nil value)

Nevertheless:

But the best fix is for Luakit to stop doing this provide the function in a module for you to use normally.

I agree.

Unrelatedly, the last line would be better as this instead

Ah so instead of explicitly using tset, the above form is equivalent to overwriting the function defined with that name in that table?

from fennel.

technomancy avatar technomancy commented on September 15, 2024

Oh dear, if they've removed _G altogether then that's probably a lost cause and you'll need to turn off strict global checks altogether. You can do that with: require("fennel").install({allowedGlobals=false}).dofile("/home/colin/.config/luakit/config.fnl")

That goof might be enough to report to them as a bug; they really shouldn't be leaving the globals table out altogether.

from fennel.

fosskers avatar fosskers commented on September 15, 2024

It shall be done, that's for the feedback.

Update: Oops... even with allowsGlobals=false it's still failing, claiming interleave doesn't exist. Either way I'll still report this upstream.

from fennel.

fosskers avatar fosskers commented on September 15, 2024

Mysteriously fixed by following this example: luakit/luakit#782 (comment)

It looks like the lambda label_maker has multi-arity, and can accept an arg. The arg is a table containing the missing symbols, like interleave. This is otherwise undocumented but is hinted at in the code.

EDIT: It is technically documented, just very vaguely:

This function is executed on the web process, with a custom environment that provides access to the label composer functions.

from fennel.

Related Issues (20)

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.