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

No errors displayed when expected #529

Open
perrylets opened this issue Oct 19, 2024 · 2 comments
Open

No errors displayed when expected #529

perrylets opened this issue Oct 19, 2024 · 2 comments

Comments

@perrylets
Copy link

I just started using ols with VS Code and noticed some cases where the code can't compile but no error appears on screen:

#+private
package odin_test

main :: proc() {
  return 1
}

No error appears but odin check shows:

odin-test/main.odin(7:10) Error: No return values expected 
        return 1
               ^

If I change the signature of main to return an int:

#+private
package odin_test

main :: proc() -> int {
  return 1
}

There won't be any errors on the screen but odin check shows:

odin-test/main.odin(4:1) Error: Procedure type of 'main' was expected to be 'proc()', got proc() -> int 
        main :: proc() -> int {
        ^

If I call a procedure that doesn't exist, it won't appear on intellisense (obviously) but no error or warning appears saying I'm calling something that isn't real:

#+private
package odin_test

main :: proc() {
  foo()
}

odin check shows:

odin-test/main.odin(5:3) Error: Undeclared name: foo 
        foo()
        ^~^ 

The same thing happens to "calling methods" or trying to access inexistent fields:

#+private
package odin_test

import "core:fmt"

main :: proc() {
  x := 0
  x.foo()
  x->bar()
  fmt.println(x.etc)
}

odin check shows:

odin-test/main.odin(8:3) Error: 'x' of type 'int' has no field 'foo' 
        x.foo()
        ^ 

odin-test/main.odin(9:3) Error: 'x' of type 'int' has no field 'bar'
        x->bar()
        ^ 

odin-test/main.odin(10:15) Error: 'x' of type 'int' has no field 'etc'
        fmt.println(x.etc)
                    ^
@DanielGavin
Copy link
Owner

I can't reproduce it. You will have to describe the exact project configuration. Your ols.json for odin check configuration. How you call the odin check manually.

Ideally to get the exact same odin check you need to set up in ols.json:

"profile": "default",
"profiles": [
		{ "name": "default", "checker_path": ["src/main.odin"]}
]

@perrylets
Copy link
Author

I can reproduce the second example. All the others work as expected now and I tested with the same config as before (I didn't delete the directory).

This is my config:

{
	"$schema": "https://raw.githubusercontent.com/DanielGavin/ols/master/misc/ols.schema.json",
	"profiles": [{ "name": "default", "checker_path": ["."] }],
	"enable_document_symbols": true,
	"enable_hover": true,
	"enable_snippets": true,
	"enable_references": true,
	"enable_format": true,
	"enable_rename": true,
	"enable_semantic_tokens": true,
	"enable_inlay_hints": true,
	"enable_inlay_hints_params": true,
	"enable_inlay_hints_default_params": true,
	"enable_fake_methods": true
}

In case it matters this is my odinfmt.json:

{
	"$schema": "https://raw.githubusercontent.com/DanielGavin/ols/master/misc/odinfmt.schema.json",
	"character_width": 80,
	"tabs": false,
	"tabs_width": 2,
	"spaces": 2,
	"brace_style": "_1TBS",
	"convert_do": true,
	"newline_style": "LF",
	"newline_limit": 2
}

main.odin is located in the same directory as the config file. All other files shouldn't affect how ols behaves because it's just some vscode settings to change what files are displayed in the explorer and a .gitignore file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants