Incorrect namespace in VAPI at "throw" statement when generating a static library
Tested versions:
- Vala 0.48.18
- Vala 0.52.4
I'm writing a project which has a Foo
namespace and a Foo
class inside.
namespace Foo.Exception
{
public errordomain PrintError
{
PRINT_FAILED
}
}
namespace Foo
{
public class Foo : Object
{
private Bar bar;
public Foo(Bar bar)
{
this.bar = bar;
}
public void sayHi()
{
try {
this.bar.sayHi();
} catch (Exception.PrintError e) {
stdout.printf("Unhandled error: \"%s\"", e.message);
}
}
public int getBarValue()
{
return this.bar.getValue();
}
}
public class Bar : Object
{
public Bar()
{
}
public void sayHi() throws Exception.PrintError
{
stdout.printf("Hi!\n");
}
public int getValue()
{
return 0;
}
}
class Main
{
public static int main()
{
var foo = new Foo(new Bar());
foo.sayHi();
return foo.getBarValue();
}
}
}
This seems to work without any problems. As you can see, I'm throwing a Foo.Exception.PrintError
error in the Foo.Bar.sayHi()
method.
If I compile this code as an executable it will build the binary without compile errors, but if I compile Foo.Foo
, Foo.Bar
and Foo.Exception.PrintError
as a library, it will generate an invalid reference to Foo.Exception.PrintError
inside the VAPI. After that, when compiling the final binary using the generated library as a dependence, the compilation will fail.
In the generated VAPI file, the generated line for sayHi
method was the following:
public void sayHi () throws Foo.Exception.PrintError;
When it should be (if I'm not mistaken)
public void sayHi () throws global::Foo.Exception.PrintError;
or
public void sayHi () throws Exception.PrintError;
Manually changing the VAPI to one of this lines will allow compiling the project with a static library without issues.
A sample project with a description of the issue and replication instructions (using Meson 0.58.1 as the build system) is provided in Github and attached as a zip file.