Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot read property 'token' of null when formatting a file #610

Closed
botsman opened this issue Aug 13, 2020 · 1 comment
Closed

Cannot read property 'token' of null when formatting a file #610

botsman opened this issue Aug 13, 2020 · 1 comment
Labels
bug Something isn't working enhancement New feature or request lineends line end handling sameline broken same line formatting

Comments

@botsman
Copy link

botsman commented Aug 13, 2020

Describe the bug

It was quite hard for me to reproduce the bug.
I am pretty sure it is related to multiline comments \* *\ and probably to inline function.

When I try to format the file below, I am getting an error:

 ⇒ haxelib run formatter -s core/Some.hx                      
Failed to format core/Some.hx: TypeError: Cannot read property 'token' of null

Called from /Users/pavel/.haxe/formatter/1,11,0/run.js line 4677 column 50
Called from /Users/pavel/.haxe/formatter/1,11,0/run.js line 5028 column 20
Called from /Users/pavel/.haxe/formatter/1,11,0/run.js line 4402 column 15
Called from /Users/pavel/.haxe/formatter/1,11,0/run.js line 8426 column 35
Called from /Users/pavel/.haxe/formatter/1,11,0/run.js line 8387 column 23
Called from /Users/pavel/.haxe/formatter/1,11,0/run.js line 14008 column 11
Called from /Users/pavel/.haxe/formatter/1,11,0/run.js line 14032 column 11
Called from /Users/pavel/.haxe/formatter/1,11,0/run.js line 14032 column 11
Called from /Users/pavel/.haxe/formatter/1,11,0/run.js line 14032 column 11
Called from /Users/pavel/.haxe/formatter/1,11,0/run.js line 14032 column 11



Formatted 0/1 files in 0.023 s.
Format failed on 1 files
-------------------------
Input lines:  19
Output lines: 0
-------------------------

Input file

class Some {
  public function makeRequest(request: String, callback: Dynamic->Void) {
    callback(request);
  }

  public function first(): Void {
    var request: String = "asd";
    this.makeRequest(
      request,
      /* some multiline comment
       */
      function(response: Dynamic) {
        var data = haxe.Json.parse(response);
        var path = StringTools.replace(data.content, "some_value", data.some_id);
      }
    );
  }
}
@AlexHaxe
Copy link
Member

in current git version it doesn't show an error (it does for 1.11.0 release version), however it should format that multiline comment better (reduced sample code):

class Some {
	public function first():Void {
		makeRequest(/* some multiline comment
		 */ function(response:Dynamic) {
			replace("some_value");
		});
	}
}

@AlexHaxe AlexHaxe added enhancement New feature or request lineends line end handling sameline broken same line formatting bug Something isn't working labels Aug 13, 2020
AlexHaxe added a commit to AlexHaxe/haxe-formatter that referenced this issue Nov 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request lineends line end handling sameline broken same line formatting
Projects
None yet
Development

No branches or pull requests

2 participants