Odin icon indicating copy to clipboard operation
Odin copied to clipboard

Confusing compiler error message

Open ftphikari opened this issue 3 years ago • 4 comments

package bug2

import win32 "core:sys/windows"

backbuffer: win32.BITMAPINFO

main :: proc() {
	backbuffer.bmiHeader.biSize = size_of(win32.BITMAPINFO.bmiHeader)
}

Compiler error:

'win32.BITMAPINFO' of type 'BITMAPINFO' has no field 'bmiHeader'
	Suggestion: Did you mean?
		bmiHeader

ftphikari avatar Mar 20 '22 12:03 ftphikari

The syntax in your code example is not valid. In order to access struct fields you need an instantiated struct.

The following will solve the Issue:

size_of(win32.Bitmap_Info{}.header) // struct instantiation with {}

As side note, you would access "constant fields" of a struct with your syntax.

Foo :: struct(N: int) {}
num := Foo(42).N

However, the compiler error message is highly confusing and should be corrected (so maybe keep this Issue open).

awwdev avatar Mar 20 '22 12:03 awwdev

However, the compiler error message is highly confusing and should be corrected (so maybe keep this Issue open).

Yes, that is indeed the issue, not my syntax, but the compiler reaction to it.

ftphikari avatar Mar 20 '22 15:03 ftphikari

Hello!

I am marking this issue as stale as it has not received any engagement from the community or maintainers 120 days. That does not imply that the issue has no merit! If you feel strongly about this issue

  • open a PR referencing and resolving the issue;
  • leave a comment on it and discuss ideas how you could contribute towards resolving it;
  • leave a comment and describe in detail why this issue is critical for your use case;
  • open a new issue with updated details and a plan on resolving the issue.

The motivation for this automation is to help prioritize issues in the backlog and not ignore, reject, or belittle anyone..

github-actions[bot] avatar Jul 24 '22 21:07 github-actions[bot]

Updated code:

package bug2

import win32 "core:sys/windows"

backbuffer: win32.BITMAPINFO

main :: proc() {
	backbuffer.bmiHeader.biSize = size_of(win32.BITMAPINFO.bmiHeader)
}

ftphikari avatar Sep 15 '22 10:09 ftphikari

With recent commits the error became:

Type 'win32.BITMAPINFO' has no field 'bmiHeader'
	... buffer.bmiHeader.biSize = size_of(win32. ...
	                                            ^

However it is still wrong.

ftphikari avatar Feb 23 '23 22:02 ftphikari