Bug 165219 - Basic interpreter doesn’t accept Variant function parameters if they may be used as Object
Summary: Basic interpreter doesn’t accept Variant function parameters if they may be u...
Status: RESOLVED DUPLICATE of bug 160578
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
24.2.5.2 release
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-02-12 14:31 UTC by Corneloup
Modified: 2025-02-12 14:58 UTC (History)
0 users

See Also:
Crash report or crash signature:


Attachments
Macro Main shows the problem (15.60 KB, application/vnd.oasis.opendocument.text)
2025-02-12 14:31 UTC, Corneloup
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Corneloup 2025-02-12 14:31:32 UTC
Created attachment 199168 [details]
Macro Main shows the problem

If a function declares a Variant parameter, and if this parameter may be used as an object somewhere in the function, it is no longer possible to call this function with a non objet parameter.

For exemple :
Function example(param as Variant)
	If IsObject(param) Then : result = param.getURL()
	Else                    : result = "param is not an object"
	End If
	example() = result
End Function

Calling example(ThisComponent) is OK and returns the document URL
But calling example("a string") generate an error "undefined parameter"

The error doesn't appear if param is not used as an objet. For instance by copying it to a local variable, replacing  
result = param.getURL()
by 
obj = param: result = obj.getURL()
Comment 1 Mike Kaganski 2025-02-12 14:58:57 UTC

*** This bug has been marked as a duplicate of bug 160578 ***