felixhao28/JSCPP

C++ Typing error

Opened this issue · 1 comments

As referred to from: viebel/klipse#300

Code that is invalid and should not compile is instead being executed and run up until the point in the source code that it fails.

The linked issue contains of note:

I was attempting to demonstrate C++ type errors that happen at compile time in a demonstration post using klipse, however the typing error seemed to happen at run-time instead of parsing/compilation time as prior lines of code were run and output information before the typing error was hit, which completely destroyed my argument for C++ that catching type errors at compile-time prior to run-time helped prevent classes of errors before the code is executed. ^.^;

Just go to any of the C++ fields at: http://blog.overminddl1.com/posts/programming-language-differences-compilation/

Then input:

#include <iostream>
using namespace std;
int main() {
  char *hw = "Hello World!";
  cout << hw << endl;
  cout << 2 * hw << endl;
  return 0;
}

I'd expect it to just print out:

6:11 unsigned int does not support * on char[13]

Instead it prints:

Hello World!

6:11 unsigned int does not support * on char[13]

That's why JSCPP is called an interpreter. It can only detect grammar errors prior to execution.