Compile error with empty class

I get this error in a web project. I have not changed anything in the session object since the last compilation. But now the error appears. I also don’t see where I could change Session.Name.

So, I tested and found the absolute minimum for reproducing this:

https://nözl.de/0ux28

This Video show a complete clean and new webproject.
Just added one module and two classes to the module. The second class has “WebListBoxCellRenderer” as super.
Running it, results in this “Session.Name” error.

Marius

Can confirm. In this case, a project that shows the problem is very helpful so I made one: name.xojo_xml_project

To get it fixed, open an issues ticket.

5 Likes

I feel like I find bugs in Xojo every day. I’ve created a few tickets over the years, but no one has ever really been interested in them. However, the effort is quite high. That’s why I - if I could find some time - now post them here. Then others will find them and know: Not my fault.
If anyone still has the energy to open a ticket for things, please feel free to do so.

2 Likes

Issue: #75356 - Session.Name error on empty class with super WebListBoxCellRenderer

3 Likes

This isn’t a bug.
I take that back, part of this is a bug.

Just so you understand…
That class is the super class of for making your own cell renderers using the WebSDK and there are methods or events that you are required to implement for it to work.

the error you are getting is because when the IDE goes to render the session at compile time, it is asking your custom renderer for something and without your code it gets nothing back, causing the code to be invalid.

In this case, the Event Handlers for Deserialize, JavascriptClassCode and Serialize must be implemented and return a valid value. Please look at the Button Cell example in Extras > WebSDK > Examples > WebListBox Cell Renderers.

That said…

The bug here is that the IDE isn’t handling this superclass for items within a module that are marked as “Public”. That means that when it goes to render the code that makes this thing work, it’s writing the code as: var tmp as B as opposed to var tmp as Module1.B like it should. You can check this yourself by changing the scope to Global and the problem goes away.

Make sure this info gets put on your case, it should be fairly trivial for them to fix.

2 Likes

As for the reason the error shows up the way it does, the IDE can’t show you the code of Session because some of it’s precompiled and some is added as glue code afterwards. What gets rendered into your project is a subclass of WebSession called Session with all of your properties and methods plus the rendered glue code based on what you’ve put in your project. The .Name property is just a placeholder for where the code might be.

1 Like

This was exactly the issue. It will be fixed in 2024r1.

Thanks for reporting the issue.

PS: Please report your own issues with your own example projects, otherwise we might end up fixing something completely different to what you’ve encountered.

2 Likes

Hi Greg,

thank you very much for your detailed answer.

This Part I could not see. Of course, what you see in my video is a very basic version to reproduce this error. My code (without these methods/events) runs fine when not in a module. And, of course, in my real world project there are these methods and events, otherwise these class(es) would make absolutely no sense. :wink:
So here having these or don’t having these makes no difference.

Jepp, this is the Bug, and nothing more or less. That is what I said.Thanks for some additional information, what Xojo is doing there.

Yes I already did and noticed that. Same as having the Classes directly in the Project. But in the real world, I’m having stacked modules here (Root → AODA → Web) in that case this “workaround” doesn’t fit, because there is no global.

This is the biggest problem in this case. By far the most time I spend developing with Xojo is looking for bugs that produce a horrible error message.
Things like (Xojo) internal event loops, IDE crashes, or even this message.
I understand and fix regular error messages within seconds. But these cases often take hours because debugging is in this case incredibly time-consuming.
This is perhaps not particularly annoying when you are working on a project for weeks. However, I often develop software with a deadline of just a few hours, so this (as well as the countless workarounds that you get used to over the years) is simply a show stopper.
So I could not agree with “the IDE can’t show you”. Even though I understand the background and see the problems. It is simply not a good practise to display such error messages (and in other cases even none at all) in such cases.

That information actually tells you the whole problem. Did you see how your error says

Did you mean class ...

The time when this error shows up in a compile is when you are using a class name that doesn’t have the right scope in your code.

Just saying, if you had included that info in the original post, we might have gotten to the answer more quickly.

Yes, for shure. But all classes I use have the right scope in my code. This is a problem in Xojo-Internal Code. The Message points to Session.Name and a refers to a wrong scope, that is absolutely not correct (from the xojo-users point of view). Xojo is a Black Box for every normal user, so this is information from this black box that is completely confusing for an outsider. So it is hard to debug.

Which Information do you mean? What is missing? The fact that i have stacked moduls? The fact that this class is not global? I don’t think this would have made anything more quickly. You don’t need stacked modules to (re)produce this error. And, of course, global would work, if that class works when putting it in the project-root (outside the module). As you said, it was clear, this has to be a scope problem.

That the class in question was enclosed in a module with its scope set to public.

I’m not trying to start a fight, just to indicate that it was a crucial part of the puzzle. I personally spent 30 minutes figuring out the actual problem, but I have “previous knowledge” because of the time I spent working on the Xojo IDE. Time = Money

Hmm, ok. I don’t mean any offence, but how do you understand my description in the initial post?

If I do that I get exactly that. A public class inside a Module. If I want it to be global, I have to change that.
I don’t see, why i should mention defaultvalues.

The crucial part was that the class’ scope was set to Public.

Yes, I understand that. I just did it again to be shure: If I create a new project, add a module and then a class to this module. It is set to public by default. If I had set it to something else then the default I would had mentioned that. But it is default, global is not default. Normally I use never ever global. Maybe once in 10000 cases.

I don’t think Greg is telling you to change to Global, he only mentioned:

Ricardo said:

So thanks to you, this bug is fixed for next release.