prajwalch / yazap

🔧 The ultimate Zig library for seamless command line argument parsing.
https://prajwalch.github.io/yazap
MIT License
152 stars 13 forks source link

Fix const ptr compiler error #2

Closed signaryk closed 2 years ago

signaryk commented 2 years ago

Zig version: 0.10.0-dev.3685+dae7aeb33

When trying to integrate this library into another project I encountered an error regarding the parse.tokenizer.Token class. I was able to reproduce this same error when running the library's tests:

$ zig build test
/src/zig-arg/src/parser/Parser.zig:120:18: error: expected type '*parser.tokenizer.Token', found '*const parser.tokenizer.Token'
        if (token.isShortFlag() or token.isLongFlag()) {
            ~~~~~^~~~~~~~~~~~
/src/zig-arg/src/parser/Parser.zig:120:18: note: cast discards const qualifier
error: test...

By replacing all occurrences of token: *Token with token: *const Token in the function definitions in src/parser/Parser.zig and src/parser/tokenizer.zig this error is no longer encountered.

This is likely caused by some recent changes in the master branch of the Zig compiler.