Repository: kcl-lang/kcl (language: rust)

Issue:
[WIP] Feat : Support Call Kclvm Cli by C API
<!-- Thank you for contributing to KusionStack!

Note: 

1. With pull requests:

    - Open your pull request against "main"
    - Your pull request should have no more than two commits, if not you should squash them.
    - It should pass all tests in the available continuous integration systems such as GitHub Actions.
    - You should add/modify tests to cover your proposed code changes.
    - If your pull request contains a new feature, please document it on the README.

2. Please create an issue first to describe the problem.

    We recommend that link the issue with the PR in the following question.
    For more info, check https://kusionstack.io/docs/governance/contribute/
-->

#### 1. Does this PR affect any open issues?(Y/N) and add issue references (e.g. "fix #123", "re #123".):

- [ ] N
- [x] Y 
re #125 

#### 2. What is the scope of this PR (e.g. component or file name):

<!-- You can add the scope of this change here. 
-->
        KCLVM/kclvm/spec
        KCLVM/kclvm/src/lib.rs

#### 3. Provide a description of the PR(e.g. more details, effects, motivations or doc link):

<!-- You can choose a brief description here -->
- [ ] Affects user behaviors
- [ ] Contains syntax changes
- [ ] Contains variable changes
- [x] Contains experimental features
- [ ] Performance regression: Consumes more CPU
- [ ] Performance regression: Consumes more Memory
- [ ] Other

<!-- You can add more details here.
-->
    Support user to call kclvm_cli by c_api


#### 4. Are there any breaking changes?(Y/N) and describe the breaking changes(e.g. more details, motivations or doc link):

- [x] N
- [ ] Y 

<!-- You can add more details here.

-->

#### 5. Are there test cases for these changes?(Y/N) select and add more details, references or doc links:

<!-- You can choose a brief description here -->
- [x] Unit test
- [ ] Integration test
- [ ] Benchmark (add benchmark stats below)
- [ ] Manual test (add detailed scripts or steps below)
- [ ] Other

<!-- You can add more details here.
None
-->
KCLVM/kclvm/src/api_test.rs

#### 6. Release note

<!-- compatibility change, improvement, bugfix, and new feature need a release note -->

Please refer to [Release Notes Language Style Guide](https://kusionstack.io/docs/governance/release-policy/) to write a quality release note.

```release-note
None
```



Discussion / hints:
****CLA Assistant Lite bot**** All contributors have signed the CLA  ✍️ ✅
I have read the CLA Document and I hereby sign the CLA
## Pull Request Test Coverage Report for [Build 2744948016](https://coveralls.io/builds/51191024)

* **2** of **5523**   **(0.04%)**  changed or added relevant lines in **6** files are covered.
* No unchanged relevant lines lost coverage.
* Overall coverage decreased (**-7.6%**) to **51.731%**

---

|  Changes Missing Coverage | Covered Lines | Changed/Added Lines | % |
| :-----|--------------|--------|---: |
| [kclvm/spec/src/main.rs](https://coveralls.io/builds/51191024/source?filename=kclvm%2Fspec%2Fsrc%2Fmain.rs#L2) | 1 | 3 | 33.33%
| [kclvm/spec/src/service/util.rs](https://coveralls.io/builds/51191024/source?filename=kclvm%2Fspec%2Fsrc%2Fservice%2Futil.rs#L2) | 0 | 25 | 0.0%
| [kclvm/spec/src/service/service.rs](https://coveralls.io/builds/51191024/source?filename=kclvm%2Fspec%2Fsrc%2Fservice%2Fservice.rs#L10) | 0 | 109 | 0.0%
| [kclvm/spec/src/service/api.rs](https://coveralls.io/builds/51191024/source?filename=kclvm%2Fspec%2Fsrc%2Fservice%2Fapi.rs#L10) | 0 | 153 | 0.0%
| [kclvm/spec/src/model/gpyrpc.rs](https://coveralls.io/builds/51191024/source?filename=kclvm%2Fspec%2Fsrc%2Fmodel%2Fgpyrpc.rs#L28) | 0 | 5232 | 0.0%
<!-- | **Total:** | **2** | **5523** | **0.04%** | -->


|  Totals | [![Coverage Status](https://coveralls.io/builds/51191024/badge)](https://coveralls.io/builds/51191024) |
| :-- | --: |
| Change from base [Build 2743999583](https://coveralls.io/builds/51186839): |  -7.6% |
| Covered Lines: | 22244 |
| Relevant Lines: | 42999 |

---
##### 💛  - [Coveralls](https://coveralls.io)


Fix patch:
diff --git a/kclvm/api/src/service/service_impl.rs b/kclvm/api/src/service/service_impl.rs
index a53716bbd..192abf6e3 100644
--- a/kclvm/api/src/service/service_impl.rs
+++ b/kclvm/api/src/service/service_impl.rs
@@ -223,9 +223,9 @@ impl KclvmServiceImpl {
     /// assert_eq!(result.type_errors.len(), 0);
     /// assert_eq!(result.symbols.len(), 12);
     /// assert_eq!(result.scopes.len(), 3);
-    /// assert_eq!(result.node_symbol_map.len(), 183);
-    /// assert_eq!(result.symbol_node_map.len(), 183);
-    /// assert_eq!(result.fully_qualified_name_map.len(), 193);
+    /// assert_eq!(result.node_symbol_map.len(), 187);
+    /// assert_eq!(result.symbol_node_map.len(), 187);
+    /// assert_eq!(result.fully_qualified_name_map.len(), 197);
     /// assert_eq!(result.pkg_scope_map.len(), 3);
     /// ```
     #[inline]
diff --git a/kclvm/runtime/src/net/mod.rs b/kclvm/runtime/src/net/mod.rs
index 168fbec97..37e6ebe95 100644
--- a/kclvm/runtime/src/net/mod.rs
+++ b/kclvm/runtime/src/net/mod.rs
@@ -513,16 +513,25 @@ pub extern "C" fn kclvm_net_is_IP_in_CIDR(
         if let Some(cidr) = get_call_arg_str(args, kwargs, 1, Some("cidr")) {
             let parts: Vec<&str> = cidr.split('/').collect();
             if parts.len() == 2 {
-                let ip = parts[0];
-                let mask = parts[1];
-                if let Ok(ip) = Ipv4Addr::from_str(ip) {
-                    if let Ok(mask) = mask.parse::<u8>() {
-                        let mask = u32::from_be_bytes(ip.octets()) & !((1 << (32 - mask)) - 1);
-                        let ip = u32::from_be_bytes(ip.octets());
-                        let x = (ip & mask) == mask;
-                        return kclvm_value_Bool(ctx, x as i8);
-                    }
-                }
+                let cidr_ip = parts[0];
+                let mask_bits = parts[1];
+                let ip_addr = match Ipv4Addr::from_str(&ip) {
+                    Ok(ip_addr) => ip_addr,
+                    Err(_) => return kclvm_value_False(ctx),
+                };
+                let cidr_ip_addr = match Ipv4Addr::from_str(cidr_ip) {
+                    Ok(cidr_ip_addr) => cidr_ip_addr,
+                    Err(_) => return kclvm_value_False(ctx),
+                };
+                let mask_bits = match mask_bits.parse::<u8>() {
+                    Ok(mask_bits) if mask_bits <= 32 => mask_bits,
+                    _ => return kclvm_value_False(ctx),
+                };
+                let mask = !((1 << (32 - mask_bits)) - 1);
+                let ip_u32 = u32::from_be_bytes(ip_addr.octets());
+                let cidr_ip_u32 = u32::from_be_bytes(cidr_ip_addr.octets());
+                let is_in_cidr = (ip_u32 & mask) == (cidr_ip_u32 & mask);
+                return kclvm_value_Bool(ctx, is_in_cidr as i8);
             }
         }
         return kclvm_value_False(ctx);
diff --git a/kclvm/sema/src/builtin/system_module.rs b/kclvm/sema/src/builtin/system_module.rs
index ceda2b74a..d5ca7420b 100644
--- a/kclvm/sema/src/builtin/system_module.rs
+++ b/kclvm/sema/src/builtin/system_module.rs
@@ -217,7 +217,7 @@ register_net_member! {
         false,
         None,
     )
-    is_IP =>Type::function(
+    is_IP => Type::function(
         None,
         Type::bool_ref(),
         &[
@@ -233,7 +233,7 @@ register_net_member! {
         false,
         None,
     )
-    is_loopback_IP =>Type::function(
+    is_loopback_IP => Type::function(
         None,
         Type::bool_ref(),
         &[
@@ -249,7 +249,7 @@ register_net_member! {
         false,
         None,
     )
-    is_multicast_IP =>Type::function(
+    is_multicast_IP => Type::function(
         None,
         Type::bool_ref(),
         &[
@@ -281,7 +281,7 @@ register_net_member! {
         false,
         None,
     )
-    is_link_local_multicast_IP =>Type::function(
+    is_link_local_multicast_IP => Type::function(
         None,
         Type::bool_ref(),
         &[
@@ -297,7 +297,7 @@ register_net_member! {
         false,
         None,
     )
-    is_link_local_unicast_IP =>Type::function(
+    is_link_local_unicast_IP => Type::function(
         None,
         Type::bool_ref(),
         &[
@@ -313,7 +313,7 @@ register_net_member! {
         false,
         None,
     )
-    is_global_unicast_IP =>Type::function(
+    is_global_unicast_IP => Type::function(
         None,
         Type::bool_ref(),
         &[
@@ -347,7 +347,7 @@ register_net_member! {
     )
     parse_CIDR => Type::function(
         None,
-        Type::dict_ref(Type::str_ref(), Type::str_ref()),
+        Type::dict_ref(Type::str_ref(), Type::any_ref()),
         &[
             Parameter {
                 name: "cidr".to_string(),
@@ -387,14 +387,7 @@ register_net_member! {
                 has_default: false,
                 default_value: None,
                 range: dummy_range(),
-            },
-            Parameter {
-                name: "new_prefix".to_string(),
-                ty: Type::int_ref(),
-                has_default: false,
-                default_value: None,
-                range: dummy_range(),
-            },
+            }
         ],
         r#"Split a CIDR block into smaller subnets with a given prefix."#,
         false,


Test patch:
diff --git a/kclvm/loader/src/snapshots/kclvm_loader__tests__builtin_call_0.snap b/kclvm/loader/src/snapshots/kclvm_loader__tests__builtin_call_0.snap
index 75f13b884..aa60d2f4d 100644
--- a/kclvm/loader/src/snapshots/kclvm_loader__tests__builtin_call_0.snap
+++ b/kclvm/loader/src/snapshots/kclvm_loader__tests__builtin_call_0.snap
@@ -1,6 +1,7 @@
 ---
 source: loader/src/tests.rs
 expression: "format! (\"{:#?}\", p.symbols.values())"
+snapshot_kind: text
 ---
 [
     SymbolInfo {
@@ -88,34 +89,6 @@ expression: "format! (\"{:#?}\", p.symbols.values())"
             },
         ),
         attrs: [
-            SymbolRef {
-                id: Index {
-                    index: 141,
-                    generation: 0,
-                },
-                kind: Function,
-            },
-            SymbolRef {
-                id: Index {
-                    index: 142,
-                    generation: 0,
-                },
-                kind: Function,
-            },
-            SymbolRef {
-                id: Index {
-                    index: 143,
-                    generation: 0,
-                },
-                kind: Function,
-            },
-            SymbolRef {
-                id: Index {
-                    index: 144,
-                    generation: 0,
-                },
-                kind: Function,
-            },
             SymbolRef {
                 id: Index {
                     index: 145,
@@ -298,6 +271,34 @@ expression: "format! (\"{:#?}\", p.symbols.values())"
                 },
                 kind: Function,
             },
+            SymbolRef {
+                id: Index {
+                    index: 171,
+                    generation: 0,
+                },
+                kind: Function,
+            },
+            SymbolRef {
+                id: Index {
+                    index: 172,
+                    generation: 0,
+                },
+                kind: Function,
+            },
+            SymbolRef {
+                id: Index {
+                    index: 173,
+                    generation: 0,
+                },
+                kind: Function,
+            },
+            SymbolRef {
+                id: Index {
+                    index: 174,
+                    generation: 0,
+                },
+                kind: Function,
+            },
         ],
         is_global: false,
     },
diff --git a/kclvm/loader/src/snapshots/kclvm_loader__tests__builtin_call_1.snap b/kclvm/loader/src/snapshots/kclvm_loader__tests__builtin_call_1.snap
index 37124b641..2a13b2c65 100644
--- a/kclvm/loader/src/snapshots/kclvm_loader__tests__builtin_call_1.snap
+++ b/kclvm/loader/src/snapshots/kclvm_loader__tests__builtin_call_1.snap
@@ -1,6 +1,7 @@
 ---
 source: loader/src/tests.rs
 expression: "format! (\"{:#?}\", p.symbols.values())"
+snapshot_kind: text
 ---
 [
     SymbolInfo {
@@ -245,34 +246,6 @@ expression: "format! (\"{:#?}\", p.symbols.values())"
             },
         ),
         attrs: [
-            SymbolRef {
-                id: Index {
-                    index: 141,
-                    generation: 0,
-                },
-                kind: Function,
-            },
-            SymbolRef {
-                id: Index {
-                    index: 142,
-                    generation: 0,
-                },
-                kind: Function,
-            },
-            SymbolRef {
-                id: Index {
-                    index: 143,
-                    generation: 0,
-                },
-                kind: Function,
-            },
-            SymbolRef {
-                id: Index {
-                    index: 144,
-                    generation: 0,
-                },
-                kind: Function,
-            },
             SymbolRef {
                 id: Index {
                     index: 145,
@@ -455,6 +428,34 @@ expression: "format! (\"{:#?}\", p.symbols.values())"
                 },
                 kind: Function,
             },
+            SymbolRef {
+                id: Index {
+                    index: 171,
+                    generation: 0,
+                },
+                kind: Function,
+            },
+            SymbolRef {
+                id: Index {
+                    index: 172,
+                    generation: 0,
+                },
+                kind: Function,
+            },
+            SymbolRef {
+                id: Index {
+                    index: 173,
+                    generation: 0,
+                },
+                kind: Function,
+            },
+            SymbolRef {
+                id: Index {
+                    index: 174,
+                    generation: 0,
+                },
+                kind: Function,
+            },
         ],
         is_global: false,
     },
@@ -494,34 +495,6 @@ expression: "format! (\"{:#?}\", p.symbols.values())"
             },
         ),
         attrs: [
-            SymbolRef {
-                id: Index {
-                    index: 141,
-                    generation: 0,
-                },
-                kind: Function,
-            },
-            SymbolRef {
-                id: Index {
-                    index: 142,
-                    generation: 0,
-                },
-                kind: Function,
-            },
-            SymbolRef {
-                id: Index {
-                    index: 143,
-                    generation: 0,
-                },
-                kind: Function,
-            },
-            SymbolRef {
-                id: Index {
-                    index: 144,
-                    generation: 0,
-                },
-                kind: Function,
-            },
             SymbolRef {
                 id: Index {
                     index: 145,
@@ -704,6 +677,34 @@ expression: "format! (\"{:#?}\", p.symbols.values())"
                 },
                 kind: Function,
             },
+            SymbolRef {
+                id: Index {
+                    index: 171,
+                    generation: 0,
+                },
+                kind: Function,
+            },
+            SymbolRef {
+                id: Index {
+                    index: 172,
+                    generation: 0,
+                },
+                kind: Function,
+            },
+            SymbolRef {
+                id: Index {
+                    index: 173,
+                    generation: 0,
+                },
+                kind: Function,
+            },
+            SymbolRef {
+                id: Index {
+                    index: 174,
+                    generation: 0,
+                },
+                kind: Function,
+            },
         ],
         is_global: false,
     },
@@ -743,34 +744,6 @@ expression: "format! (\"{:#?}\", p.symbols.values())"
             },
         ),
         attrs: [
-            SymbolRef {
-                id: Index {
-                    index: 141,
-                    generation: 0,
-                },
-                kind: Function,
-            },
-            SymbolRef {
-                id: Index {
-                    index: 142,
-                    generation: 0,
-                },
-                kind: Function,
-            },
-            SymbolRef {
-                id: Index {
-                    index: 143,
-                    generation: 0,
-                },
-                kind: Function,
-            },
-            SymbolRef {
-                id: Index {
-                    index: 144,
-                    generation: 0,
-                },
-                kind: Function,
-            },
             SymbolRef {
                 id: Index {
                     index: 145,
@@ -953,6 +926,34 @@ expression: "format! (\"{:#?}\", p.symbols.values())"
                 },
                 kind: Function,
             },
+            SymbolRef {
+                id: Index {
+                    index: 171,
+                    generation: 0,
+                },
+                kind: Function,
+            },
+            SymbolRef {
+                id: Index {
+                    index: 172,
+                    generation: 0,
+                },
+                kind: Function,
+            },
+            SymbolRef {
+                id: Index {
+                    index: 173,
+                    generation: 0,
+                },
+                kind: Function,
+            },
+            SymbolRef {
+                id: Index {
+                    index: 174,
+                    generation: 0,
+                },
+                kind: Function,
+            },
         ],
         is_global: false,
     },
diff --git a/kclvm/loader/src/snapshots/kclvm_loader__tests__builtin_call_2.snap b/kclvm/loader/src/snapshots/kclvm_loader__tests__builtin_call_2.snap
index ed383b2de..c4a2a17ae 100644
--- a/kclvm/loader/src/snapshots/kclvm_loader__tests__builtin_call_2.snap
+++ b/kclvm/loader/src/snapshots/kclvm_loader__tests__builtin_call_2.snap
@@ -1,6 +1,7 @@
 ---
 source: loader/src/tests.rs
 expression: "format! (\"{:#?}\", p.symbols.values())"
+snapshot_kind: text
 ---
 [
     SymbolInfo {
@@ -577,34 +578,6 @@ expression: "format! (\"{:#?}\", p.symbols.values())"
             },
         ),
         attrs: [
-            SymbolRef {
-                id: Index {
-                    index: 141,
-                    generation: 0,
-                },
-                kind: Function,
-            },
-            SymbolRef {
-                id: Index {
-                    index: 142,
-                    generation: 0,
-                },
-                kind: Function,
-            },
-            SymbolRef {
-                id: Index {
-                    index: 143,
-                    generation: 0,
-                },
-                kind: Function,
-            },
-            SymbolRef {
-                id: Index {
-                    index: 144,
-                    generation: 0,
-                },
-                kind: Function,
-            },
             SymbolRef {
                 id: Index {
                     index: 145,
@@ -787,6 +760,34 @@ expression: "format! (\"{:#?}\", p.symbols.values())"
                 },
                 kind: Function,
             },
+            SymbolRef {
+                id: Index {
+                    index: 171,
+                    generation: 0,
+                },
+                kind: Function,
+            },
+            SymbolRef {
+                id: Index {
+                    index: 172,
+                    generation: 0,
+                },
+                kind: Function,
+            },
+            SymbolRef {
+                id: Index {
+                    index: 173,
+                    generation: 0,
+                },
+                kind: Function,
+            },
+            SymbolRef {
+                id: Index {
+                    index: 174,
+                    generation: 0,
+                },
+                kind: Function,
+            },
         ],
         is_global: false,
     },
@@ -826,34 +827,6 @@ expression: "format! (\"{:#?}\", p.symbols.values())"
             },
         ),
         attrs: [
-            SymbolRef {
-                id: Index {
-                    index: 141,
-                    generation: 0,
-                },
-                kind: Function,
-            },
-            SymbolRef {
-                id: Index {
-                    index: 142,
-                    generation: 0,
-                },
-                kind: Function,
-            },
-            SymbolRef {
-                id: Index {
-                    index: 143,
-                    generation: 0,
-                },
-                kind: Function,
-            },
-            SymbolRef {
-                id: Index {
-                    index: 144,
-                    generation: 0,
-                },
-                kind: Function,
-            },
             SymbolRef {
                 id: Index {
                     index: 145,
@@ -1036,6 +1009,34 @@ expression: "format! (\"{:#?}\", p.symbols.values())"
                 },
                 kind: Function,
             },
+            SymbolRef {
+                id: Index {
+                    index: 171,
+                    generation: 0,
+                },
+                kind: Function,
+            },
+            SymbolRef {
+                id: Index {
+                    index: 172,
+                    generation: 0,
+                },
+                kind: Function,
+            },
+            SymbolRef {
+                id: Index {
+                    index: 173,
+                    generation: 0,
+                },
+                kind: Function,
+            },
+            SymbolRef {
+                id: Index {
+                    index: 174,
+                    generation: 0,
+                },
+                kind: Function,
+            },
         ],
         is_global: false,
     },
@@ -1075,34 +1076,6 @@ expression: "format! (\"{:#?}\", p.symbols.values())"
             },
         ),
         attrs: [
-            SymbolRef {
-                id: Index {
-                    index: 141,
-                    generation: 0,
-                },
-                kind: Function,
-            },
-            SymbolRef {
-                id: Index {
-                    index: 142,
-                    generation: 0,
-                },
-                kind: Function,
-            },
-            SymbolRef {
-                id: Index {
-                    index: 143,
-                    generation: 0,
-                },
-                kind: Function,
-            },
-            SymbolRef {
-                id: Index {
-                    index: 144,
-                    generation: 0,
-                },
-                kind: Function,
-            },
             SymbolRef {
                 id: Index {
                     index: 145,
@@ -1285,6 +1258,34 @@ expression: "format! (\"{:#?}\", p.symbols.values())"
                 },
                 kind: Function,
             },
+            SymbolRef {
+                id: Index {
+                    index: 171,
+                    generation: 0,
+                },
+                kind: Function,
+            },
+            SymbolRef {
+                id: Index {
+                    index: 172,
+                    generation: 0,
+                },
+                kind: Function,
+            },
+            SymbolRef {
+                id: Index {
+                    index: 173,
+                    generation: 0,
+                },
+                kind: Function,
+            },
+            SymbolRef {
+                id: Index {
+                    index: 174,
+                    generation: 0,
+                },
+                kind: Function,
+            },
         ],
         is_global: false,
     },
diff --git a/kclvm/loader/src/snapshots/kclvm_loader__tests__import_stmt_0.snap b/kclvm/loader/src/snapshots/kclvm_loader__tests__import_stmt_0.snap
index 254a718db..5284ad512 100644
--- a/kclvm/loader/src/snapshots/kclvm_loader__tests__import_stmt_0.snap
+++ b/kclvm/loader/src/snapshots/kclvm_loader__tests__import_stmt_0.snap
@@ -1,6 +1,7 @@
 ---
 source: loader/src/tests.rs
-expression: "format!(\"{:#?}\", p.symbols.values())"
+expression: "format! (\"{:#?}\", p.symbols.values())"
+snapshot_kind: text
 ---
 [
     SymbolInfo {
@@ -47,112 +48,112 @@ expression: "format!(\"{:#?}\", p.symbols.values())"
         attrs: [
             SymbolRef {
                 id: Index {
-                    index: 46,
+                    index: 50,
                     generation: 0,
                 },
                 kind: Function,
             },
             SymbolRef {
                 id: Index {
-                    index: 47,
+                    index: 51,
                     generation: 0,
                 },
                 kind: Function,
             },
             SymbolRef {
                 id: Index {
-                    index: 48,
+                    index: 52,
                     generation: 0,
                 },
                 kind: Function,
             },
             SymbolRef {
                 id: Index {
-                    index: 49,
+                    index: 53,
                     generation: 0,
                 },
                 kind: Function,
             },
             SymbolRef {
                 id: Index {
-                    index: 50,
+                    index: 54,
                     generation: 0,
                 },
                 kind: Function,
             },
             SymbolRef {
                 id: Index {
-                    index: 51,
+                    index: 55,
                     generation: 0,
                 },
                 kind: Function,
             },
             SymbolRef {
                 id: Index {
-                    index: 52,
+                    index: 56,
                     generation: 0,
                 },
                 kind: Function,
             },
             SymbolRef {
                 id: Index {
-                    index: 53,
+                    index: 57,
                     generation: 0,
                 },
                 kind: Function,
             },
             SymbolRef {
                 id: Index {
-                    index: 54,
+                    index: 58,
                     generation: 0,
                 },
                 kind: Function,
             },
             SymbolRef {
                 id: Index {
-                    index: 55,
+                    index: 59,
                     generation: 0,
                 },
                 kind: Function,
             },
             SymbolRef {
                 id: Index {
-                    index: 56,
+                    index: 60,
                     generation: 0,
                 },
                 kind: Function,
             },
             SymbolRef {
                 id: Index {
-                    index: 57,
+                    index: 61,
                     generation: 0,
                 },
                 kind: Function,
             },
             SymbolRef {
                 id: Index {
-                    index: 58,
+                    index: 62,
                     generation: 0,
                 },
                 kind: Function,
             },
             SymbolRef {
                 id: Index {
-                    index: 59,
+                    index: 63,
                     generation: 0,
                 },
                 kind: Function,
             },
             SymbolRef {
                 id: Index {
-                    index: 60,
+                    index: 64,
                     generation: 0,
                 },
                 kind: Function,
             },
             SymbolRef {
                 id: Index {
-                    index: 61,
+                    index: 65,
                     generation: 0,
                 },
                 kind: Function,
@@ -248,112 +249,112 @@ expression: "format!(\"{:#?}\", p.symbols.values())"
         attrs: [
             SymbolRef {
                 id: Index {
-                    index: 46,
+                    index: 50,
                     generation: 0,
                 },
                 kind: Function,
             },
             SymbolRef {
                 id: Index {
-                    index: 47,
+                    index: 51,
                     generation: 0,
                 },
                 kind: Function,
             },
             SymbolRef {
                 id: Index {
-                    index: 48,
+                    index: 52,
                     generation: 0,
                 },
                 kind: Function,
             },
             SymbolRef {
                 id: Index {
-                    index: 49,
+                    index: 53,
                     generation: 0,
                 },
                 kind: Function,
             },
             SymbolRef {
                 id: Index {
-                    index: 50,
+                    index: 54,
                     generation: 0,
                 },
                 kind: Function,
             },
             SymbolRef {
                 id: Index {
-                    index: 51,
+                    index: 55,
                     generation: 0,
                 },
                 kind: Function,
             },
             SymbolRef {
                 id: Index {
-                    index: 52,
+                    index: 56,
                     generation: 0,
                 },
                 kind: Function,
             },
             SymbolRef {
                 id: Index {
-                    index: 53,
+                    index: 57,
                     generation: 0,
                 },
                 kind: Function,
             },
             SymbolRef {
                 id: Index {
-                    index: 54,
+                    index: 58,
                     generation: 0,
                 },
                 kind: Function,
             },
             SymbolRef {
                 id: Index {
-                    index: 55,
+                    index: 59,
                     generation: 0,
                 },
                 kind: Function,
             },
             SymbolRef {
                 id: Index {
-                    index: 56,
+                    index: 60,
                     generation: 0,
                 },
                 kind: Function,
             },
             SymbolRef {
                 id: Index {
-                    index: 57,
+                    index: 61,
                     generation: 0,
                 },
                 kind: Function,
             },
             SymbolRef {
                 id: Index {
-                    index: 58,
+                    index: 62,
                     generation: 0,
                 },
                 kind: Function,
             },
             SymbolRef {
                 id: Index {
-                    index: 59,
+                    index: 63,
                     generation: 0,
                 },
                 kind: Function,
             },
             SymbolRef {
                 id: Index {
-                    index: 60,
+                    index: 64,
                     generation: 0,
                 },
                 kind: Function,
             },
             SymbolRef {
                 id: Index {
-                    index: 61,
+                    index: 65,
                     generation: 0,
                 },
                 kind: Function,
@@ -459,7 +460,7 @@ expression: "format!(\"{:#?}\", p.symbols.values())"
         def: Some(
             SymbolRef {
                 id: Index {
-                    index: 56,
+                    index: 60,
                     generation: 0,
                 },
                 kind: Function,
diff --git a/test/grammar/builtins/net/cidr/main.k b/test/grammar/builtins/net/cidr/main.k
new file mode 100644
index 000000000..a565992b0
--- /dev/null
+++ b/test/grammar/builtins/net/cidr/main.k
@@ -0,0 +1,7 @@
+import net
+
+cidr0 = net.parse_CIDR("192.168.1.0/24")
+cidr1 = net.hosts_in_CIDR("192.168.1.0/24")
+cidr2 = net.subnets_from_CIDR("192.168.1.0/24")
+cidr3 = net.is_IP_in_CIDR("192.168.1.1", "192.168.1.0/24")
+cidr4 = net.is_IP_in_CIDR("192.168.0.1", "192.168.1.0/24")
diff --git a/test/grammar/builtins/net/cidr/stdout.golden b/test/grammar/builtins/net/cidr/stdout.golden
new file mode 100644
index 000000000..eec869f8a
--- /dev/null
+++ b/test/grammar/builtins/net/cidr/stdout.golden
@@ -0,0 +1,7 @@
+cidr0:
+  ip: '192.168.1.0'
+  mask: 24
+cidr1: []
+cidr2: []
+cidr3: true
+cidr4: false
diff --git a/test/grammar/builtins/net/is_ip_2/main.k b/test/grammar/builtins/net/is_ip_2/main.k
index bed34c0c5..d215848d3 100644
--- a/test/grammar/builtins/net/is_ip_2/main.k
+++ b/test/grammar/builtins/net/is_ip_2/main.k
@@ -6,8 +6,3 @@ isip2 = net.is_link_local_multicast_IP("224.0.0.0")
 isip3 = net.is_link_local_unicast_IP("fe80::2012:1")
 isip4 = net.is_global_unicast_IP("220.181.108.89")
 isip5 = net.is_unspecified_IP("0.0.0.0")
-isip6 = net.parse_CIDR("192.168.1.0/24")
-isip7 = net.hosts_in_CIDR("192.168.1.0/24")
-isip8 = net.subnets_from_CIDR("192.168.1.0/24")
-isip9 = net.is_IP_in_CIDR("192.168.1.1", "192.168.1.0/24")
-