Support struct values as constants #25

Closed
opened 2025-08-27 10:08:42 +00:00 by Furkan · 1 comment

Constants work for integers and strings but doesn't work for custom structs

Color {
	r byte
	g byte
	b byte
	a byte
}

const {
	BLACK = Color{0, 0, 0, 255}
	WHITE = Color{255, 255, 255, 255}
}

main() {
}
Constants work for integers and strings but doesn't work for custom structs ``` Color { r byte g byte b byte a byte } const { BLACK = Color{0, 0, 0, 255} WHITE = Color{255, 255, 255, 255} } main() { } ```
ed self-assigned this 2025-08-27 10:23:14 +00:00
ed changed title from Couldn't define contant structs to Support structs as constants 2025-08-27 10:24:00 +00:00
ed changed title from Support structs as constants to Support struct values as constants 2025-08-27 10:24:19 +00:00
Owner

This is now implemented in 493286364e.

See the relevant test files:

This is now implemented in https://git.urbach.dev/cli/q/commit/493286364e03a21bdc8d359e37b3837e434c182c. See the relevant test files: - [const.q](https://git.urbach.dev/cli/q/src/commit/493286364e03a21bdc8d359e37b3837e434c182c/tests/const.q) - [const-expr.q](https://git.urbach.dev/cli/q/src/commit/493286364e03a21bdc8d359e37b3837e434c182c/tests/const-expr.q) - [const-string.q](https://git.urbach.dev/cli/q/src/commit/493286364e03a21bdc8d359e37b3837e434c182c/tests/const-string.q) - [const-color.q](https://git.urbach.dev/cli/q/src/commit/493286364e03a21bdc8d359e37b3837e434c182c/tests/const-color.q)
ed added spent time 2026-06-12 12:34:19 +00:00
2 hours
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Total time spent: 2 hours
ed
2 hours
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#25
No description provided.