Photoshop behaves differently when I "tell" a reference to a document

tell application "/Applications/Adobe Photoshop CS6/Adobe Photoshop"
	tell the current document
		set {docWidth1, docHeight1} to {the width as pixels, the height as pixels}
	end tell
	set currentDoc to the current document
	tell currentDoc
		set {docWidth2, docHeight2} to {the width as pixels, the height as pixels}
	end tell
	set class1 to the class of docWidth1
	set class2 to the class of docWidth2
	return {docWidth1, docHeight1, class1, docWidth2, docHeight2, class2}
end tell

{1200.0, 1200.0, real, pixels 1200.0, pixels 1200.0, pixels}

So if you “tell the current document,” then the document size specified “as pixels” is the numerical value of the size of the document, but if you first set a reference to the document, then tell the reference, then the document size specified “as pixels” is a Photoshop defined variable class “pixels” holding the value.

I had thought “tell” a reference would always be the same as a direct “tell” statement.

The implementation of that object class must be fairly recent; it wasn’t an option in CS3, and, perhaps, all the kinks weren’t worked out. Try avoiding the coercions by declaring the desired units in advance.

tell application "Adobe Photoshop CS3"
	set settings's ruler units to pixel units
	tell current document to set {docWidth1, docHeight1, currentDoc} to {width, height, it}
	{docWidth1, docHeight1, currentDoc's width} --all reals
end tell

I posted mainly because I was curious… and I wonder how many other things in PS might behave differently.

I had already worked around it using

 set {docWidth1, docHeight1} to {the width as pixels as number, the height as pixels as number}

I never mess with ruler settings or any other program settings if I can possibly avoid it, because if the script crashes partway through it leaves their settings changed. The script not only changes them back at the end, but I’ve also tried reading their current setting first and wrapping the entire script in a “try” with and “on error” that checks their ruler settings against that first variable and changes it back if it’s wrong, and somehow people still say it changes their settings.