In a Google Sheet cell, a custom function is being called through =sheetName() to run the following script (that will return current sheet name):
function sheetName() {
return SpreadsheetApp.getActiveSpreadsheet().getActiveSheet().getName();
}
On first edit (code insertion in cell) the function works properly, but since the sheet is renamed the function won't work as the cell (calling the custom function) content is not updated. Editing again the cell will show the error "Unknown function":
At this point, some editing in the "offending" cell, will correctly run again the custom function...
Any idea why the function will only work when cell content is edited and wont run when sheet "tab" is renamed?

renameActiveSheet("Hello world");to the new value and then update it into the cell