Issue 3488

Fix for #3488.
Needs tests.
Needs to fix the pretty printer. (Help appreciated.)