
Why does Math.Round open a print window from a browser in Try .NET
Today, public attention was drawn to a funny illogical bug discovered in Try .NET , a tool designed to embed interactive examples in C # in documentation. You can see the open issue on Github at the link .
The given code, when executed (when calling the Math.Round method ) instead of the expected result, suddenly opens the print window from the browser:

Using the error trace and breakpoints, users found an alleged reason for this behavior - it was hidden in the mono.js library .

The answer is simple. Apparently, someone wanted to use their own print () function in JS (or confused it with console.log ), but since it was not found in the scope, the program calls window.print () , which really should open the print window of the current document - because window is a global object for the main stream in the browser.
This fallback was not immediately noticed, but one of the users claims that this error was fixed last November .
In order to avoid situations in which errors of this kind occur, the create-react-app project maintains a list of "confusing" browser global variables , since it is quite simple to make a similar error:
The given code, when executed (when calling the Math.Round method ) instead of the expected result, suddenly opens the print window from the browser:
using System;
public class Example
{
public static void Main()
{
var x = Math.Round(11.1, MidpointRounding.AwayFromZero);
}
}

Using the error trace and breakpoints, users found an alleged reason for this behavior - it was hidden in the mono.js library .

The answer is simple. Apparently, someone wanted to use their own print () function in JS (or confused it with console.log ), but since it was not found in the scope, the program calls window.print () , which really should open the print window of the current document - because window is a global object for the main stream in the browser.
This fallback was not immediately noticed, but one of the users claims that this error was fixed last November .
In order to avoid situations in which errors of this kind occur, the create-react-app project maintains a list of "confusing" browser global variables , since it is quite simple to make a similar error:
handleClick() { // пропущен аргумент `event`
this.setState({
text: event.target.value // используется глобальная переменная `event`- ошибка!
});
}