fix js stacktraces, unify all file,line,col formatting into a single function (#14230)

* fix https://github.com/timotheecour/Nim/issues/135 ; unify all file,line,col formatting into a single function
This commit is contained in:
Timothee Cour 2020-05-05 05:56:15 -07:00 • committed by GitHub
commit c28a057a6b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 68 additions and 46 deletions

View file

@ -1,17 +1,17 @@
when not declared(sysFatal):
include "system/fatal"
import std/private/miscdollars
# ---------------------------------------------------------------------------
# helpers
type InstantiationInfo = tuple[filename: string, line: int, column: int]
proc `$`(x: int): string {.magic: "IntToStr", noSideEffect.}
proc `$`(info: InstantiationInfo): string =
# The +1 is needed here
# instead of overriding `$` (and changing its meaning), consider explicit name.
info.filename & "(" & $info.line & ", " & $(info.column+1) & ")"
result.toLocation(info.filename, info.line, info.column+1)
# ---------------------------------------------------------------------------