Hi Garry,
I've been trying the new C# backend in 26.10.3 and have run into a compile error that doesn't occur with the VM backend. I've reduced it to a small repro.
Repro: a class nested inside a module calls a function in that module without using the module prefix.
Module Tree
Function Greeting(name As String) As String
Return "hello " + name
End Function
End Module
# Class Holder, nested in module Tree (ParentModule = Tree)
Class Holder
Function Dump() As String
Return Greeting("world")
End Function
End Class
The app's Run method just does:
Print(New Tree.Holder().Dump())
With the VM backend:
objo check C03.objosln --backend vm reports no errors.
- The build runs and prints
hello world.
With the C# backend:
objo check C03.objosln --backend csharp fails with:
Error: Tree.Holder:3:8: The checked variable requires global, captured or member storage outside C03.
objo build … --backend csharp fails with the same message, but gives the location as Tree:8:8, which is a line in the module rather than in Holder.
I saw the same thing in my real project. check pointed to the correct line, while build reported Ast:244:14, even though the Ast module only has 230 lines, so the location reported by build looks to be off as well.
A bit more narrowing down:
- Changing the call to
Tree.Greeting("world") makes the error go away.
- Inheritance, generics and array arguments don't seem to be involved. I tested them separately and the error remained.
The workaround is to qualify module calls from nested classes. That's straightforward in a small project, but my real project ......
Tested on macOS arm64 with Objo Studio 26.10.3 and the objo command-line tool from the same build.