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

std.Build.option: Improve type detection logic #20435

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Lzard
Copy link

@Lzard Lzard commented Jun 27, 2024

Improves the type detection logic of option to more accurately raise errors for all invalid types.

Currently, passing any pointer-to-u8 or pointer-to-enum type other than []const u8 or []const AnEnum raises unhelpful compile errors elsewhere in the code.

(split from original #20412)

Comment on lines +1544 to +1546
const complex_type: ?TypeId = switch (@typeInfo(T)) {
.Int => .int,
.Float => .float,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you also add the comptime variants here? Tihs would allow using .{ .foo = 10 }

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This requires turning those values into strings, as they would be if they were passed through command line arguments; I made it into a separate PR since the code that needs to be changed is in another function: #20499

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

Successfully merging this pull request may close these issues.

None yet

2 participants