lgi-devs / lgi-devs/lgi

struct field not writable

Open
#111 21 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Lua
Stars
491
Forks
81
PR merge metrics
No merged PRs in 30d

Description

I wanted to add my own file descriptor to the glib main loop.
Trying to create a "SourceFuncs":

local GLib = require"lgi".GLib
GLib.SourceFuncs {
    prepare = print;
    check = print;
    dispatch = print;
    finalize = print
}
/usr/share/lua/5.3/lgi/record.lua:94: GLib.SourceFuncs: field `finalize' is not writable
stack traceback:
    [C]: in field 'field'
    /usr/share/lua/5.3/lgi/record.lua:94: in function </usr/share/lua/5.3/lgi/record.lua:68>
    (...tail calls...)
    [C]: in metamethod '__newindex'
    /usr/share/lua/5.3/lgi/record.lua:129: in function </usr/share/lua/5.3/lgi/record.lua:113>
    (...tail calls...)
    [C]: in ?

Same error happens if you create the SourceFuncs first and try and add the field:

local GLib = require"lgi".GLib
funcs = GLib.SourceFuncs()
funcs.prepare = print
/usr/share/lua/5.3/lgi/record.lua:94: GLib.SourceFuncs: field `prepare' is not writable
stack traceback:
    [C]: in field 'field'
    /usr/share/lua/5.3/lgi/record.lua:94: in function </usr/share/lua/5.3/lgi/record.lua:68>
    (...tail calls...)
    [C]: in metamethod '__newindex'
    stdin:1: in main chunk
    [C]: in ?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with record.lua at the reported lines 94 and 129, then reproduce the GLib.SourceFuncs construction and field assignments from the issue. Trace why prepare, check, dispatch, and finalize are rejected as non-writable; done means the reported assignments work without the field error and the existing behavior remains intact.

Written by the indexing model from the issue text.

Assessment

Tech stack
lua
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.