feat: add Bool type support across Rust and Lua APIs#344
Draft
feat: add Bool type support across Rust and Lua APIs#344
Conversation
Luacheck Report3 tests 3 ✅ 0s ⏱️ Results for commit 2ba1185. ♻️ This comment has been updated with latest results. |
There was a problem hiding this comment.
Pull request overview
Adds first-class boolean literal/type support to the ATC DSL and wires it through the Rust core plus the Lua FFI wrappers, so matchers can compare schema fields against true/false.
Changes:
- Extend DSL grammar/parser/AST/semantics to support
Boolvalues andtrue/falseliterals. - Add interpreter and Rust unit/integration tests for boolean comparisons.
- Update Lua schema/context bindings and generated FFI cdefs to pass boolean values into the Rust engine.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| t/08-equals.t | Adds an OpenResty integration test for == / != with Bool fields. |
| src/semantics.rs | Allows Bool LHS for equality ops and adds validation tests. |
| src/schema.rs | Extends schema test coverage to include Type::Bool. |
| src/parser.rs | Parses bool_literal into Value::Bool. |
| src/interpreter.rs | Adds predicate execution test cases for Bool equality/inequality. |
| src/ffi/router.rs | Removes deprecated constant usage in tests (inlines buffer size). |
| src/ffi/mod.rs | Extends CValue and conversion to include Bool. |
| src/ffi/expression.rs | Removes deprecated constant usage in tests (inlines buffer size). |
| src/atc_grammar.pest | Adds bool_literal and includes it in rhs. |
| src/ast.rs | Adds Value::Bool, Type::Bool, formatting, and parse/display tests. |
| lib/resty/router/schema.lua | Maps "Bool" to the correct C enum type. |
| lib/resty/router/context.lua | Supports adding Bool values and fixes nil-check so false is not dropped. |
| lib/resty/router/cdefs.lua | Updates FFI definitions for Type::Bool and CValue_Bool. |
| README.md | Documents Bool type and shows usage in the Lua example. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Previously, add_value would silently fall through without updating CACHED_VALUE when called with an unsupported field type (e.g. IpCidr, Regex), causing stale data to be passed into the FFI call. Now returns an explicit error instead. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The comment was missing rawstr_literal after it was added to the grammar. Now mirrors the grammar definition exactly. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
chobits
commented
Mar 20, 2026
src/ffi/expression.rs
Outdated
Comment on lines
+221
to
+222
|
|
||
| const ERR_BUF_MAX_LEN: usize = 4096; |
Contributor
Author
There was a problem hiding this comment.
this is not a good way to fix this issue,
and also i foudn that our Ci workflow does not include "cargo test"
Contributor
Author
|
based on this #328, i re-implement boolean support |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Use case: I'm adding field to context called
plugins.xxx.is_access_executed() == true/falseto indicate whether the some plugins in kong was executed. This is related to plugin conditional expression feature in kong.