-
Notifications
You must be signed in to change notification settings - Fork 4
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
Support for disabling functions with feature flags #333
Comments
Unfortunately, I don't think this will be possible. Handling feature flags properly is a too heavy job for static analysis. On the other hand, I think this should be improved. Maybe just ignore duplicated one if the signatures match, and raise an error if the signatures don't match?
|
Thanks for your reply!
I think that makes sense. |
@eitsupi https://github.com/yutannihilation/savvy/releases/tag/v0.8.3-rc.1 |
Thanks for the update! #[cfg(not(target_arch = "wasm32"))]
#[savvy]
impl PlRExpr {
fn str_json_path_match(&self, pat: &PlRExpr) -> Result<Self> {
Ok(self
.inner
.clone()
.str()
.json_path_match(pat.inner.clone())
.into())
}
}
#[cfg(target_arch = "wasm32")]
#[savvy]
impl PlRExpr {
#[allow(unused_variables)]
fn str_json_path_match(&self, pat: &PlRExpr) -> Result<Self> {
Err(RPolarsErr::Other(format!("Not supported in WASM")).into())
}
} I am wondering if the following pattern are also supported (I will have time to try within the next few days) #[savvy]
impl PlRExpr {
#[cfg(not(target_arch = "wasm32"))]
fn str_json_path_match(&self, pat: &PlRExpr) -> Result<Self> {
Ok(self
.inner
.clone()
.str()
.json_path_match(pat.inner.clone())
.into())
}
#[cfg(target_arch = "wasm32")]
#[allow(unused_variables)]
fn str_json_path_match(&self, pat: &PlRExpr) -> Result<Self> {
Err(RPolarsErr::Other(format!("Not supported in WASM")).into())
}
} |
This pattern does not seems supported. |
Thanks for testing. Let me check. |
I can't reproduce the problem. What error do you see when you run |
Ah, sorry, I hit the problem. Please forget my comment above.
|
It turned out that the problem is on |
Thanks for the update!
|
This version should work! |
Confirmed in eitsupi/neo-r-polars#50, thanks! |
Great. Let's merge and release then! |
We may want to disable a function that does not work on a particular platform by using a feature flag.
For example, the following functions in Python Polars do not work on WASM and will be disabled in the build for WASM.
https://github.com/pola-rs/polars/blob/f5f4cb55e98c60f723036b932796d972104b5f93/crates/polars-python/src/expr/string.rs#L243-L246
Compiling the following code, which does the same thing using savvy, yields an error.
https://github.com/eitsupi/neo-r-polars/blob/14b234c300779ef4e7d0612bbfe9aaac03d8502e/src/rust/src/expr/string.rs#L114-L123
https://github.com/eitsupi/neo-r-polars/actions/runs/12536892771/job/34960399544
Using the following approach, Rust compiles successfully, but the R package build fails because multiple functions with the same name are generated on the C file generated by the
savvy-cli update
command.The text was updated successfully, but these errors were encountered: