Bug 166781 - [BASIC] Redundant End Sub error - code does not compile
Summary: [BASIC] Redundant End Sub error - code does not compile
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
24.8.7.2 release
Hardware: x86-64 (AMD64) Windows (All)
: medium normal
Assignee: Mike Kaganski
URL:
Whiteboard: target:25.8.0
Keywords:
Depends on:
Blocks: BASIC-IDE
  Show dependency treegraph
 
Reported: 2025-05-29 08:52 UTC by Cameron
Modified: 2025-06-09 16:54 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
LibreOffice Calc file containing the macros for testing [USE THIS FOR TESTING] (11.57 KB, application/vnd.oasis.opendocument.spreadsheet)
2025-05-29 08:53 UTC, Cameron
Details
Gif showing step-by-step macro showcasing the redundant "End Sub" error (1.98 MB, image/gif)
2025-05-29 08:54 UTC, Cameron
Details
[OFF-TOPIC] Submission form requirements (116.25 KB, image/png)
2025-06-09 16:54 UTC, Cameron
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Cameron 2025-05-29 08:52:51 UTC
Description:
In one of my macros, LibreOffice would not allow it to work because of an apparently missing "End Sub" (which is not the case).

If I add another - redundant - End Sub afterwards, it works.

Steps to Reproduce:
1.Test the two macros available (one with € format that displays the error, one without)
2.Keep only one sub at the end of the "MacroWithError"
3.See the error

Actual Results:
Missing "End Sub" error.

Expected Results:
Should not contain an error. The macro should work properly.


Reproducible: Always


User Profile Reset: No

Additional Info:
Version: 24.8.7.2 (X86_64) / LibreOffice Community
Build ID: e07d0a63a46349d29051da79b1fde8160bab2a89
CPU threads: 8; OS: Windows 10 X86_64 (10.0 build 19045); UI render: Skia/Raster; VCL: win
Locale: fr-FR (fr_FR); UI: fr-FR
Calc: CL threaded
Comment 1 Cameron 2025-05-29 08:53:29 UTC
Created attachment 201020 [details]
LibreOffice Calc file containing the macros for testing [USE THIS FOR TESTING]
Comment 2 Cameron 2025-05-29 08:54:51 UTC
Created attachment 201021 [details]
Gif showing step-by-step macro showcasing the redundant "End Sub" error
Comment 3 Olivier Hallot 2025-05-29 13:00:58 UTC
Confirmed

Version: 25.2.3.2 (X86_64) / LibreOffice Community
Build ID: bbb074479178df812d175f709636b368952c2ce3
CPU threads: 12; OS: Linux 6.14; UI render: default; VCL: kf5 (cairo+wayland)
Locale: pt-BR (pt_BR.UTF-8); UI: pt-BR
Calc: threaded
Comment 4 Commit Notification 2025-05-29 13:03:21 UTC
Mike Kaganski committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/44cdfa2eee54f6ead849fd998abe1c3c58b67398

tdf#166781: Emit correct expected token on missing End If

It will be available in 25.8.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 5 Cameron 2025-05-29 13:38:44 UTC
(In reply to Commit Notification from comment #4)
> Mike Kaganski committed a patch related to this issue.

Thanks to Mike who will probably express an embarrassed grin reading this (given our recent troubled history) :)

Looking forward 25.8.0 then.
Comment 6 Mike Kaganski 2025-05-29 13:43:35 UTC
Huh?

But thank you for such a poor code, that allowed to find a problem with our compiler showing "missing end sub", where it needed to say "missing end if".
Comment 7 Cameron 2025-05-29 14:24:08 UTC Comment hidden (off-topic)
Comment 8 Commit Notification 2025-05-31 19:51:16 UTC
Mike Kaganski committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/a4d1a55fa6c84e662d8a64fb16b70abed155fd75

Add another test for tdf#166781

It will be available in 25.8.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 9 Buovjaga 2025-06-03 18:53:48 UTC Comment hidden (off-topic)
Comment 10 Cameron 2025-06-07 08:56:00 UTC Comment hidden (off-topic)
Comment 11 Mike Kaganski 2025-06-07 09:14:59 UTC Comment hidden (off-topic)
Comment 12 Mike Kaganski 2025-06-07 09:43:29 UTC Comment hidden (off-topic)
Comment 13 Cameron 2025-06-08 18:01:14 UTC
(In reply to Mike Kaganski from comment #11)

> but (a) the
> submissions need to comply with the requirements to bug reports; and (b)
> there may be requests to clarify. 

Agree with you here and I am pretty sure I did everything by the book according the submission form requirements (if not more if we consider the examples provided).

> And no, this is not a place where we treat
> you as a "customer", and exercise "politeness" in ways common in shops. I
> e.g. just make plain statements; and if someone is too proud of their
> "filing bugs" skill, and reads my "your screenshots are useless to
> reproduce", and suddenly start feeling they are offended - it's not my
> problem, it's a problem of bug submitter's wrong expectations. And you are
> free to just not submit anything, if you are too sensitive.

> That last statement is astonishingly arrogant. But first, let me tell that it 
> shows that you showed, how you didn't try to read and understand both by 
> comments there - where I asked not for "simplified version of your work" - I 
> asked for a simple code in ten lines, which is muck easier, than even recording > those GIFs you did.

It is not a question of treating me as a customer. I am not a customer here since I am not buying anything. I am taking some of my free time (as you are) for the same objective (pointing errors & improving LO, in a nutshell).

It is about understanding the context. You pointed out correctly that our communication started with bug 166232 comment 9 but you did not - in my opinion - analyzed the relatively concise yet explanatory information I provided about the bug and how it happened.

In that same comment, you asked for a simple code, without sharing a test-file. In other words, you asked me to summarize 225 lines of code into 4 a perform a test. Here are major issues with this request in my point of view:

- Summarizing 225 lines of code of personal work into 4 shareable lines of code is near impossible: the bug reported is linked too many factors (dialogbox properties, variables,..) so it cannot be summarised to just a conversion function and a msgbox (to take up your example). If I was encountering an issue in using the conversion function or in displaying the converted value into a msgbox, I would have changed my bug description and shortened it to just that.

Also, unfortunately, a lot of bugs happen in complex environment. In my case, it involves 225 lines (give or take) but that is quite small considering the usual number of lines involved in the development community.

- The second issue lies on the fact of asking to provide a sample code and then asking the bug-reporter to perform a test on its own computer but then ditch the visual results/conclusions he provided: how can you positively understand how the bug happened with just a few lines of code and believe the hazardous written conclusion the bug-reporter will provide? 
The answer: you cannot. Because if you believe those written conclusions without confirming them from your point of view, you take the risk in trying to fix things in the wrong direction.

The GIFs and detailed description were meant to answer that issue.

So I did provide the summarized code as you requested and its corrected version after you pointed out a missing part. Then you said that my summarized code does not work "out-of-the-box". So again, I did the work and provided a test-file you could use.

> And note also, that I (who you started to be rude to first!) [...] Your 
> immediate response was: > "I was not expecting another helpless comment like 
> this one from you".

Mate, you started off by categorizing my bug-report as obsolete, ditching the effort put into detailing in a clear and concise manner how the bug happened. I understand that it was a mistake on your end but your attitude did not really change after that (even though I went through with all your requests). Again, I am also a "volunteer" from the moment I take the time to detail & explain a bug that occurs in LO.

> I e.g. just make plain statements; and if someone is too proud of their 
> "filing bugs" skill, and > reads my "your screenshots are useless to 
> reproduce", and suddenly start feeling they are > offended - it's not my 
> problem, it's a problem of bug submitter's wrong expectations. And you are 
> free to just not submit anything, if you are too sensitive.

I really do not think you would be comfortable going down that path stating you are less sensitive than another since you demonstrated your own sensitiveness in this discussion. I think you agree that there is a way of saying things while remaining on topic and without getting too emotional. I agree I could have said some of the emotional things differently but I do not regret them since they are the result of a human-response to a disrespectful attitude towards my own efforts.
Comment 14 Mike Kaganski 2025-06-08 18:20:03 UTC
(In reply to Cameron from comment #13)

If you did not try to prove your greatness, and tried to analyze our conversation again, you would notice, that my *very first request for code* basically already guessed 100% of your problem. Go and re-read it: I suggested you to get the line of code that gives the error; check the string variable(s) there; and put these strings literally (i.e., without all that useless mass of code and dialogs and document itself), to produce the only important thing: post the string that you expect to be converted correctly, and that didn't do that. You decided that you knew better, and posted more useless stuff; in my next sample, I even posted the version with "eur" - I basically just needed to check if my conclusions were true; and you continued claiming that I misunderstand. Your attitude is not "you asked, here it is" - your attitude is "I know better what you need".

And my initial closing of your bug ... oh... Well. I went through bugs around Basic, looking for what I can fix. I found two bugs that you posted; and - well, let me not start about your so-called "skills" again, when your two bugs were so similar in wording, that I thought it was just a typical problem *caused by our server*, when people push "send" button, and nothing happens for a few seconds, and people start to think they failed to push the button, and push it again; and that makes two copies of the same report. We close the accidental submits ... you are not required to know all that; and after you reopened, I saw the mistake - but then you never even tried to see how your description was poor - when I pointed to that, you called it "unimportant"...

Well, I'm done talking to you. Please, if I one day forget about that, and decide to take and fix your bug, please remind me - I will immediately go away.
Comment 15 Cameron 2025-06-09 16:53:36 UTC
(In reply to Mike Kaganski from comment #14)
 
> If you did not try to prove your greatness, and tried to analyze our
> conversation again, you would notice, that my *very first request for code*
> basically already guessed 100% of your problem. Go and re-read it: I
> suggested you to get the line of code that gives the error; check the string
> variable(s) there; and put these strings literally (i.e., without all that
> useless mass of code and dialogs and document itself), to produce the only
> important thing: post the string that you expect to be converted correctly,
> and that didn't do that.

I don't get it...
Of course I tried using strings only from beginning to end :

[...]
Dim FieldA_string As String
Dim FieldB_string As String
[...]
FieldA_string = ActivationInterface.getControl("FieldA").Text
FieldB_string = ActivationInterface.getControl("FieldB").Text
[...]
MySheet.getCellByPosition(1, 1).Value = CDec(FieldA_string) / CDec(FieldB_string)

Anyway, Robert Großkopf understood the problem (https://bugs.documentfoundation.org/show_bug.cgi?id=166232#c21) and we eventually pointed out some complexities in using conversion functions (& room for improvement in the help of libreoffice:
- (https://bugs.documentfoundation.org/show_bug.cgi?id=166232#c27) 
- and (https://bugs.documentfoundation.org/show_bug.cgi?id=166232#c29).

> You decided that you knew better, and posted more
> useless stuff; in my next sample, I even posted the version with "eur" - I
> basically just needed to check if my conclusions were true; and you
> continued claiming that I misunderstand. Your attitude is not "you asked,
> here it is" - your attitude is "I know better what you need".

No, my attitude is definitely "you asked, here it is".
If it were "I know better what you need", I would not have gone through with your requests.

> And my initial closing of your bug ... oh... Well. I went through bugs
> around Basic, looking for what I can fix. I found two bugs that you posted;
> and - well, let me not start about your so-called "skills" again, when your
> two bugs were so similar in wording, that I thought it was just a typical
> problem *caused by our server*, when people push "send" button, and nothing
> happens for a few seconds, and people start to think they failed to push the
> button, and push it again; and that makes two copies of the same report. We
> close the accidental submits ... you are not required to know all that; and
> after you reopened, I saw the mistake - but then you never even tried to see
> how your description was poor - when I pointed to that, you called it
> "unimportant"...

Look, I will add a screenshot of the submission form. Feel free to compare the examples provided and my detailed description. I do not have many regrets on that aspect.
Comment 16 Cameron 2025-06-09 16:54:29 UTC
Created attachment 201164 [details]
[OFF-TOPIC] Submission form requirements