From d@@tt@|| @end|ng |rom gm@||@com  Thu Feb 21 00:07:32 2019
From: d@@tt@|| @end|ng |rom gm@||@com (Dean Attali)
Date: Wed, 20 Feb 2019 18:07:32 -0500
Subject: [Rd] Bug in print.default: dispatches to global show instead of
 methods::show
Message-ID: <CA+j8Z+kxiwaTZv-bLEVo_OdkT3s_Jhw0y+GqCKwZZ-CaFgn-_Q@mail.gmail.com>

This is related to a problem that was fixed in 2015
https://github.com/wch/r-source/commit/38ea40dcd0353af16d35296ee621338c49ae48c9
The problem then was that auto-printing by typing an object to the console
would search for show() in the globalenv instead of in the methods
namespace.

The problem I would like to report is that it seems that when an S4 object
is printed with print(), a similar issue happens. I do realize that S4
objects should be printed with show() rather than print(), which would
solve the issue, but this still seems like a bug to me.

Example:

library(methods)
show <- function(...) message("hijacked!")
setClass("Test", representation(test = "character"))
test <- new("Test")
print(test)
# hijacked!

	[[alternative HTML version deleted]]



[Rd] Bug in print.default: dispatches to global show instead of methods::show
Dean Attali