HaxeFoundation / HaxeFoundation/haxe
Uncaught exception Cannot call null (reproducible!)
- Dominant language
- Haxe
- Stars
- 6.9k
- Forks
- 715
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 11
Description
So far I failed to reproduce this outside VSCode, but it is 100% reproducible inside it. Might have something to do with `--cwd` calls because of the weird `changed directories: []` below.
`Main.hx`
```haxe
class Main {
static function main() {
Macro.func();
}
}
```
`Macro.hx`
```haxe
class Macro {
public static macro function func() {
var t = haxe.macro.Context.getType("Int");
trace(t);
return macro 1;
}
}
```
`build.hxml`
```hxml
-main Main
-js main.js
```
`.vscode/settings.json`
```json
{
"haxe.displayServer": {"arguments": ["-v"]},
"haxe.buildCompletionCache": false,
"haxe.enableDiagnostics": false
}
```
(so the amount of uncontrolled server calls is minimal)
1) Open this project in VSCode
2) Compile with the build task (so cache server is used)
3) Comment line 3 in `Macro.hx` (`var t = haxe.macro.Context.getType("Int");`) and save the file
4) Compile with the build task again - get the proper error (`Unknown identifier : t`)
5) Uncomment line 3 in `Macro.hx` back and save the file
6) Compile with the build task - BAM: `Macro.hx:3: characters 17-50 : Uncaught exception Cannot call null`
Haxe server output
```
Haxe language server started
Using --server-connect
Haxe connected!
Processing Arguments [--display,{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"supportsResolve":true,"exclude":["zpp_nape"],"maxCompletionItems":1000}}]
Completion Response =
{"jsonrpc":"2.0","id":0,"result":{"result":{"methods":["display/definition","server/contexts","server/moduleCreated","server/invalidate","server/module","server/files","initialize","display/completion","typer/compiledTypes","display/references","server/modules","server/memory/context","display/completionItem/resolve","display/typeDefinition","server/memory","display/implementation","display/hover","display/package","display/signatureHelp","server/memory/module","server/readClassPaths","server/configure"],"haxeVersion":{"major":4,"minor":1,"patch":0,"pre":"rc.1","build":"bc6eca1fd"},"protocolVersion":{"major":0,"minor":4,"patch":0}},"timestamp":1582399821.6802447}}
Stats = 0 files, 0 classes, 0 methods, 0 macros
Time spent : 0.000s
Listening on port 6000
Processing Arguments [--display,{"jsonrpc":"2.0","id":1,"method":"server/configure","params":{"noModuleChecks":true,"print":{"completion":false,"reusing":false},"legacyCompletion":false}}]
Stats = 0 files, 0 classes, 0 methods, 0 macros
Time spent : 0.000s
Client connected
Processing Arguments [--cwd,c:\Users\nadako\Code\playground,build.hxml]
Defines dce=std,haxe3=1,haxe4=1,haxe=4.1.0-rc.1,haxe_ver=4.100,js-es5=1,js=1,js_es5=1,js_es=5,source-header=Generated by Haxe 4.1.0-rc.1+bc6eca1fd,target.name=js,target.unicode=true,target.utf16=true,true=1,utf16=1
Using signature 84fef1af5de52a14c9c1eb15ad163b2e
Display position: ?: -1--1
0, js: Cached 48 modules
Stats = 158 files, 171 classes, 862 methods, 1 macros
Time spent : 0.150s
Client disconnected
Processing Arguments [--display,{"jsonrpc":"2.0","id":2,"method":"server/invalidate","params":{"file":"c:/Users/nadako/Code/playground/Macro.hx"}}]
Stats = 0 files, 0 classes, 0 methods, 0 macros
Time spent : 0.000s
Client connected
Processing Arguments [--cwd,c:\Users\nadako\Code\playground,build.hxml]
Defines dce=std,haxe3=1,haxe4=1,haxe=4.1.0-rc.1,haxe_ver=4.100,js-es5=1,js=1,js_es5=1,js_es=5,source-header=Generated by Haxe 4.1.0-rc.1+bc6eca1fd,target.name=js,target.unicode=true,target.utf16=true,true=1,utf16=1
Using signature 84fef1af5de52a14c9c1eb15ad163b2e
Display position: ?: -1--1
0, js: skipping Main(Macro)
0, js: skipping Macro
1,evl: skipping Macro
> Macro.hx:4: characters 15-16 : Unknown identifier : t
Macro.hx:4: characters 15-16 : For function argument 'v'
1,evl: found 35 directories
0, js: found 41 directories
Stats = 2 files, 3 classes, 2 methods, 1 macros
Time spent : 0.030s
Client disconnected
Processing Arguments [--display,{"jsonrpc":"2.0","id":3,"method":"server/invalidate","params":{"file":"c:/Users/nadako/Code/playground/Macro.hx"}}]
Stats = 0 files, 0 classes, 0 methods, 0 macros
Time spent : 0.000s
Client connected
Processing Arguments [--cwd,c:\Users\nadako\Code\playground,build.hxml]
Defines dce=std,haxe3=1,haxe4=1,haxe=4.1.0-rc.1,haxe_ver=4.100,js-es5=1,js=1,js_es5=1,js_es=5,source-header=Generated by Haxe 4.1.0-rc.1+bc6eca1fd,target.name=js,target.unicode=true,target.utf16=true,true=1,utf16=1
Using signature 84fef1af5de52a14c9c1eb15ad163b2e
Display position: ?: -1--1
0, js: changed directories: []
0, js: skipping Main(Macro)
0, js: skipping Macro
1,evl: changed directories: []
1,evl: skipping Macro
> Macro.hx:3: characters 17-50 : Uncaught exception Cannot call null
Main.hx:3: characters 3-15 : Called from here
> Main.hx:1: lines 1-5 : Defined in this class
Stats = 2 files, 3 classes, 2 methods, 1 macros
Client disconnected
Time spent : 0.005s
```
As mentioned, these `changed directories: []` look suspicious and if it is the cause, it might explain why it's so hard to reproduce as it might be related to current working directories.
Contributor guide
Assessment
This issue has not been assessed yet.