GrammaticalFramework / gf-core

Grammatical Framework core: compiler, shell & runtimes
https://www.grammaticalframework.org
Other
129 stars 35 forks source link

python runtime compiling failed #157

Open Saibo-creator opened 1 year ago

Saibo-creator commented 1 year ago

Hello, I got the following error while compiling python runtime from the source. It seems there is a function signature mimatch.

Error Reproduction

Go inside runtime/python/

python setup.py build

Error Message

pypgf.c:1740:77: error: too many arguments to function call, expected 6, have 7
                pgf_complete(self->concr, type, sentence, prefix, prefix_bind, parse_err, pyres->pool);
                ~~~~~~~~~~~~                                                              ^~~~~~~~~~~
/usr/local/include/pgf/pgf.h:253:1: note: 'pgf_complete' declared here
pgf_complete(PgfConcr* concr, PgfType* type, GuString string, 
^

Fix

Change line 1740 in pypgf.c pgf_complete(self->concr, type, sentence, prefix, prefix_bind, parse_err, pyres->pool);

to pgf_complete(self->concr, type, sentence, prefix, parse_err, pyres->pool);

Saibo-creator commented 1 year ago

After a close look, it seems that this is caused by the mismatch between the installed C runtime and python code.

In the commit a42cec21071de72806bedd2fac985fe2a1356db3 on Jul 16, 2022, the interface of pgf_complete has been changed.

The pgf_complete in the current commit is aligned with the line 1740 in pypgf.c https://github.com/GrammaticalFramework/gf-core/blob/master/src/runtime/c/pgf/pgf.h#L254 , where pgf_complete takes 7 arguments, including prefix_bind

However, if the c-runtime was installed from assets here https://github.com/GrammaticalFramework/gf-core/releases/tag/3.11 (my case) then the mismatch happens, due to the fact that the assets were compiled from the old code(before commit a42cec21071de72806bedd2fac985fe2a1356db3)

So I guess it may not be a bug, but just a caveat for beginners.