lgi-devs / lgi-devs/lgi

`version` is used as a special field, but `Vips` library have function named this way

Open
#238 5 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

After having some not so fun time trying to debug this issue (it somehow worked right way first time and I have no idea why), it looks like I've found a problem regarding Vips library.

lgi allows to take a look at version of package loaded using field called version: https://github.com/pavouk/lgi/blob/master/lgi/gi.c#L680-L684

However, Vips library have function named this way (copied from /usr/share/gir-1.0/Vips-8.0.gir):

    <function name="version" c:identifier="vips_version">
      <doc xml:space="preserve"
           filename="iofuncs/init.c"
           line="1076">Get the major, minor or micro library version, with @flag values 0, 1 and
2.

Get the ABI current, revision and age (as used by libtool) with @flag
values 3, 4, 5.</doc>
      <source-position filename="include/vips/vips.h" line="178"/>
      <return-value transfer-ownership="none">
        <doc xml:space="preserve"
             filename="iofuncs/init.c"
             line="1086">library version number</doc>
        <type name="gint" c:type="int"/>
      </return-value>
      <parameters>
        <parameter name="flag" transfer-ownership="none">
          <doc xml:space="preserve"
               filename="iofuncs/init.c"
               line="1078">which field of the version to get</doc>
          <type name="gint" c:type="int"/>
        </parameter>
      </parameters>
    </function>

As a result, lgi overrides this function and returns its own string instead. Commenting out that part of code makes everything work as intended.

It worked first time I tried it (version was a function) and I don't know why:
print(lgi.Vips:_resolve(true).version) still returns string value.

Are there any ways to work this around? Any ideas how it worked the first time?

I'd suggest to prefix all special names reserved by lgi with _ like you did with _resolve to avoid such collisions in the future, so it would be _version, _name, etc. If you agree with this, I can quickly submit a patch (they aren't documented anywhere, so it shouldn't be a big deal).

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 at lgi/gi.c lines 680-684 and inspect how the special version field is resolved for the Vips GIR version function. Confirm the binding preserves the Vips function without overriding it with package metadata, then validate the behavior using the print(lgi.Vips:_resolve(true).version) example and a Vips installation.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, lua
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 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.