Calc macros in IDE separated from Spreadsheet macros

I have macros in Basic, in the spreadsheet, and a button to run a macro. It all works fine until … I am doing HasUnoInterfaces() on some strings, and when it tries with “” it gets an error (which I cannot copy/paste so excuse the screenshot):
which is perfectly reasonable for the reason it says (although a mere misspelling of an interface is simply ignored).
The weirdness follows after that. Editing my macros in the IDE has no effect; they run as they were before the edit. Anything I do the code in the IDE has no effect from the spreadsheet, including changing the name of the macro the button executes (which should get an error on button push). I edit the code, save the code, do whatever I want in the IDE - no joy. The macros from the spreadsheet are completely separated from the macros in the IDE.
It won’t let me close the IDE because Basic is running, and clicking Run → Stop has no effect, so I can’t close the IDE and see what happens afterwards.
When I close the spreadsheet and reopen it, the version now in the IDE has none of the edits.
Somehow, it seems, the macros in the IDE get separated from the spreadsheet after the error. Is this a feature I don’t understand, or is this a problem with LibreOffice?

Version: (X86_64) / LibreOffice Community
Build ID: 60(Build:1)
CPU threads: 8; OS: Linux 5.18; UI render: default; VCL: gtk3
Locale: en-US (en_US.UTF-8); UI: en-US
Ubuntu package version: 4:7.6.4-0ubuntu0.20.04.1~lo2
Calc: threaded

You can strore your macros on two different places: In the spacific document, and in the MyMacros under the Applications. The StarBasic macros located in both of places are editable in the IDE (except, when the macros are hided somehow).
Where you have stored your macro assigned to the button?
Can you upoad your ODF type sample file here?

I realized that in some case, for the Macro to work perfectly, the IDE must be closed.

Zizi64 -
“I have macros in Basic, in the spreadsheet …”
They are stored in the spreadsheet.
Working at reducing spreadsheet & macros to upload

Schiavinatto -
It’s not a question of the macro working perfectly (it does, even after the error), it’s a question of the IDE working (editing) at all.

Notes on trimming own to demonstrate problem:
I have closed all LibreOffice windows (often have six or seven of them open at once), confirmed (System Monitor) that LibreOffice is not running, and opened only the one (renamed) spreadsheet and the IDE. Runs correctly. Put back the .table.CellRangeAddress, and error (shown above) occurs.
Additional note on behavior: After running the macro and getting the error, running the macro again does NOT get the error, but lists all the interfaces as unsupported.
Closing the IDE is not permitted “while Basic is running”; closing the spreadsheet does not solve that. “Exit LibreOffice” in the IDE gets same response. System Monitor → soffice.bin → Kill Process closes the IDE.
Bring up the spreadsheet and IDE again, does the same thing. Kill again.
Bring up spreadsheet, without IDE, execute macro and exit spreadsheet, System Monitor shows soffice.bin is gone.

Radically trim spreadsheet - insert one sheet, delete all others. Same thing.
Radically trim macros - make button macro do the HasUnoInterfaces() directly; test without “CellRangeAddress” - works well. Change back to “CellRangeAddress” and all behavior is the same.
Trim buttons - rename library, only one button, appropriately named. Gets error. Behaves same without and with IDE.

Demonstrates problem.
IDE Separation Test.ods (11.6 KB)

To demonstrate problem:
Close ALL other LibreOffice windows, because you are going to have to KILL soffice.bin
Open spreadsheet, do NOT open IDE. Click “Separate IDE” button, get error; click again, no error. Close spreadsheet, soffice.bin goes away.
Open spreadsheet, open IDE. Click “Separate IDE” button, get error; click again, no error. Close spreadsheet, close IDE, get “cannot close” error. Kill soffice.bin
Open spreadsheet, open IDE. Click “Separate IDE” button, get error; edit source in IDE (add a comment), save macros and save spreadsheet. You have to Kill soffice.bin to get out; reopen spreadsheet and see edit disappeared.
Comment added to source BEFORE separation is saved, even if save (of spreadsheet) is done AFTER separation.

So the real question remains, hoping for an answer from someone more knowledgeable or familiar with the IDE, etc. -
Is this a feature we don’t understand, or is it a problem with LibreOffice?

This is a problem with LibreOffice.

Technically, this is not a single problem, but two: first is not checking if the UNO type of the “thing” referenced by the name passed to HasUnoInterfaces is indeed an interface; and the second is a strange thing, where uncaught exception didn’t properly terminate the process, but was silently swallowed, but corrupted the program state. The latter is fixed independently recently; so now your code would not show this “unexplainable” behavior, but simply crash the program; the rest (the proper handling, raising the Basic error, and not crashing the program) awaits the proper bug report, and a fix (a check if the result of xClass->getTypeClass() call is TypeClass_INTERFACE in RTL_Impl_HasInterfaces).

The interesting point is, that obviously, calling HasUnoInterfaces with a valid UNO name that refers to not an interface is something done really rarely - I couldn’t find bugs / complaints on this.