willowtreeapps / wist

A linter for BrightScript
Apache License 2.0
43 stars 11 forks source link

String has UTF-16 code units that do not fit in 8 bits #119

Closed TwitchBronBron closed 5 years ago

TwitchBronBron commented 5 years ago

When wist encounters a character not in the supported character encoding, it completely bombs. It would be nice if wist would be able to recover a bit more gracefully, perhaps add a specific error message about that token.

Here's the sample brightscript file (note the question mark character at the end of the print statement).

sub PrintError()
    print "request failed �"
end sub

When I run this command: wist PrintError.brs, it fails with this output.

C:\Users\MY_USER_NAME\AppData\Roaming\nvm\v10.11.0\node_modules\@willowtreeapps\wist\dist\libwist.js:1 (function (exports, require, module, filename, dirname) { var Module=typeof Module!=="undefined"?Module:{};var Module={"locateFile":(function(url){const path=require("path");return path.resolve(__dirname)+"/"+url})};var moduleOverrides={};var key;for(key in Module){if(Module.hasOwnProperty(key)){moduleOverrides[key]=Module[key]}}Module["arguments"]=[];Module["thisProgram"]="./this.program";Module["quit"]=(function(status,toThrow){throw toThrow});Module["preRun"]=[];Module["postRun"]=[];var ENVIRONMENT_IS_WEB=false;var ENVIRONMENT_IS_WORKER=false;var ENVIRONMENT_IS_NODE=false;var ENVIRONMENT_IS_SHELL=false;if(Module["ENVIRONMENT"]){if(Module["ENVIRONMENT"]==="WEB"){ENVIRONMENT_IS_WEB=true}else if(Module["ENVIRONMENT"]==="WORKER"){ENVIRONMENT_IS_WORKER=true}else if(Module["ENVIRONMENT"]==="NODE"){ENVIRONMENT_IS_NODE=true}else if(Module["ENVIRONMENT"]==="SHELL"){ENVIRONMENT_IS_SHELL=true}else{throw new Error(" BindingError: String has UTF-16 code units that do not fit in 8 bits at BindingError. (C:\Users\MY_USER_NAME\AppData\Roaming\nvm\v10.11.0\node_modules\@willowtreeapps\wist\dist\libwist.js:1:102871) at new BindingError (eval at createNamedFunction (C:\Users\MY_USER_NAME\AppData\Roaming\nvm\v10.11.0\node_modules\@willowtreeapps\wist\dist\libwist.js:1:102577), :4:34) at throwBindingError (C:\Users\MY_USER_NAME\AppData\Roaming\nvm\v10.11.0\node_modules\@willowtreeapps\wist\dist\libwist.js:1:106396) at Object.toWireType (C:\Users\MY_USER_NAME\AppData\Roaming\nvm\v10.11.0\nodemodules\@willowtreeapps\wist\dist\libwist.js:1:135594) at Object.parseText (eval at new (C:\Users\MY_USER_NAME\AppData\Roaming\nvm\v10.11.0\node_modules\@willowtreeapps\wist\dist\libwist.js:1:125751), :7:26) at Linter.verify (C:\Users\MY_USER_NAME\AppData\Roaming\nvm\v10.11.0\node_modules\@willowtreeapps\wist\src\js\linter.js:141:36) at processText (C:\Users\MY_USER_NAME\AppData\Roaming\nvm\v10.11.0\node_modules\@willowtreeapps\wist\src\js\cli-engine.js:49:23) at processFile (C:\Users\MY_USER_NAME\AppData\Roaming\nvm\v10.11.0\node_modules\@willowtreeapps\wist\src\js\cli-engine.js:65:18) at executeOnFile (C:\Users\MY_USER_NAME\AppData\Roaming\nvm\v10.11.0\node_modules\@willowtreeapps\wist\src\js\cli-engine.js:89:28) at patterns.forEach.filename (C:\Users\MY_USER_NAME\AppData\Roaming\nvm\v10.11.0\node_modules\@willowtreeapps\wist\src\js\cli-engine.js:94:13)

nishtahir commented 5 years ago

My guess is that this is the same issue listed here https://github.com/emscripten-core/emscripten/issues/7174