OpenJSCAD.org icon indicating copy to clipboard operation
OpenJSCAD.org copied to clipboard

OpenSCAD Wrong line indication on import error messages

Open udif opened this issue 2 years ago • 2 comments

Expected Behavior

When an error is encountered, report the correct line number.

Actual Behavior

Under Window, the line number reported is 2 * the actual line number, probably due to \r\n counted as two lines.

Steps to Reproduce the Problem

  1. Create a fake SCAD file with a few comment lines, then a dummy error:

test.scad:

//a
//b
//c
xxxxx

And the container OpenJSCAD file:

var parser = require('@jscad/openscad-openjscad-translator')
var fs = require('fs')

var openSCADText = fs.readFileSync("test.scad", "UTF8")
var openJSCADResult = parser.parse(openSCADText)

console.log(openJSCADResult)
  1. Now run it:
node ./cli.js test.js
JSCAD: generating output
 from:  test.js
 to:  test.stl (STereoLithography, ASCII)

Function {
  message: "Parse error on line 7:\n\r\r\rxxxxx\r\n---------^\nExpecting '(', '=', got '1'",
  hash: {
    text: '',
    token: 1,
    line: 8,
    loc: { first_line: 7, last_line: 7, first_column: 0, last_column: 5 },
    expected: [ "'('", "'='" ]
  }
}
  1. As you can see, an error is reported for line 8, not 4.

Specifications

  • Version: Release : 2022 MAR 03
  • Platform: Windows 10
  • Environment: Chrome (Version 98.0.4758.102 (Official Build) (64-bit)), Latest NodsJS LTS (16.14.0), npm 8.3.1

udif avatar Mar 06 '22 11:03 udif

This is even worse in #881

z3dev avatar Apr 09 '22 23:04 z3dev

@udif sorry, but we have no plans to support SCAD to JSCAD translation at this time.

the version that you have been trying to used is very old; published 1.0.0-alpha.d0fb3056 • 3 years ago

i'll keep this issue open for those brave and bold enough to port this module to V2.

z3dev avatar Apr 30 '22 06:04 z3dev