AppleScript issue crashes SD and SE

This is clearly an AppleScript issue, since it crashes both SD and SE. But I’m passing it along here in case no one has seen it before.

set myList to {{1, 2, 3}}
set myOtherList to {{4, 5, 6}}

repeat 3 times
	set the end of myList to myList
end repeat
return myList

This script will crash both SD and SE.

But if you change the command in the repeat loop to:

set the end of myList to myOtherList

it does just fine.

Also, this often causes crashes, but not always, but it never returns a result:


repeat 3 times
	set the end of myList to myList
end repeat
return myList

and the variable viewer for myList says:

“AppleScript cannot display value”

–> Script Debugger 7.0.12 (7A112)
–> Mac OS 10.13.6 (17G14042)

The problem with this code is that it creates a recursive reference to the myList. This makes AppleScript crash when it tries to traverse the list.

Remember that the set command does not copy the value when dealing with lists and objects (it only copies scalar values). You can use the copy command to actually copy myList into its self: