title: How does a bytecode interpreter know what line a runtime error occurred on?
body: <p>As of now, I am working on a language that compiles to bytecode, and then is ran by a VM.  My question is, when a runtime error occurs, how does the VM know what line of the source code caused the error, as all whitespace is removed during the compilation process.  One thing I would think of is to store a separate array of integers correlating to the bytecode with the line numbers within it, but that sounds extremely memory-inefficient, especially when there are a lot of instructions.</p>