Bug 162983 - In VBASupport mode, it's possible to close a SUB as a FUNCTION, or close a FUNCTION as a PROPERTY
Summary: In VBASupport mode, it's possible to close a SUB as a FUNCTION, or close a FU...
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: All All
: medium normal
Assignee: Alexandru Diaconu
URL:
Whiteboard: target:25.8.0
Keywords: difficultyBeginner, easyHack, skillCpp, topicDebug
Depends on:
Blocks: 162986
  Show dependency treegraph
 
Reported: 2024-09-16 07:59 UTC by Mike Kaganski
Modified: 2025-06-05 16:28 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mike Kaganski 2024-09-16 07:59:37 UTC
Consider this Basic code:

  Option VBASupport 1

  Sub foo
  End Function

  Function bar
  End Property

This compiles and runs, even though the "End" clauses don't match respective start keywords. VBA doesn't allow that.

This was implemented in i#109075 (https://bz.apache.org/ooo/show_bug.cgi?id=109075), to support constructs like

Public Property Get Foo()
' Code...
End Sub

Yes, specifically 'Property Get' (but not 'Property Set', nor 'Property Let') allows closing it with 'End Sub' / 'End Function'; but no other variations are allowed.

The code is in SbiParser::Parse (basic/source/comp/parser.cxx). This easyhack is only about closing a Sub / Function, not about closing Property Set/Let.
Comment 1 Commit Notification 2025-05-12 14:06:15 UTC
Alexandru Diaconu committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/047c84f431064d6bf5eeff536e6f554d4e63aac3

tdf#162983 Restrict closure of Function and Sub to only End Function and Sub.

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.