Unused fields in a struct should not be reported as errors #12

Closed
opened 2025-08-17 12:33:28 +00:00 by zupa · 2 comments

Static analysis misses the use of s in:

(I wanted to implement a substring() function, this is a minimized code example.)

Code:

import io

main() {
	foo("hello world")
}

foo(s string) {
	_(s.ptr[0])
}

_(_ any) {}

Error:

tests/return-string.q:7:5

    foo(s string) {
        ┬
        ╰─ Unused value 's'
Static analysis misses the use of `s` in: (I wanted to implement a substring() function, this is a minimized code example.) Code: ``` import io main() { foo("hello world") } foo(s string) { _(s.ptr[0]) } _(_ any) {} ``` Error: ``` tests/return-string.q:7:5 foo(s string) { ┬ ╰─ Unused value 's' ```
Owner
Fixed in https://git.urbach.dev/cli/q/commit/049498c96bb4fdb047f92af0dd3b4cc9fae69ef6. Test is [ignore-unused-field.q](https://git.urbach.dev/cli/q/src/branch/main/tests/ignore-unused-field.q)
ed added spent time 2025-08-17 12:49:42 +00:00
15 minutes
ed changed title from Unused value 's' to "Unused value" error for unused fields in a struct should be ignored 2025-08-17 12:51:57 +00:00
ed changed title from "Unused value" error for unused fields in a struct should be ignored to Unused fields in a struct should not be reported as errors 2025-08-17 12:53:54 +00:00
Author

Thx!

Thx!
zupa closed this issue 2025-08-17 13:43:26 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Total time spent: 15 minutes
ed
15 minutes
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
cli/q#12
No description provided.