Commit c26118f
committed
fix: use python truthiness for compiled
JS `&&`/`||` use JS truthiness, where `[]` and `{}` are truthy. Python
treats them as falsy, so `Var([]) | true` was compiling to `[] || true`
and returning `[]` instead of `true`. Same issue for `Var({}) & x`,
`Var("") | y`, etc.
Compile `a | b` to `pyOr(a, () => b)` and `a & b` to `pyAnd(a, () => b)`,
backed by helpers that use `isTrue` for the truthiness check. RHS is
wrapped in a thunk so short-circuit semantics are preserved.and/or Var operations1 parent 6288dfe commit c26118f
3 files changed
Lines changed: 28 additions & 5 deletions
File tree
- packages/reflex-base/src/reflex_base
- .templates/web/utils
- vars
- tests/units
Lines changed: 12 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1142 | 1142 | | |
1143 | 1143 | | |
1144 | 1144 | | |
| 1145 | + | |
| 1146 | + | |
| 1147 | + | |
| 1148 | + | |
| 1149 | + | |
| 1150 | + | |
| 1151 | + | |
| 1152 | + | |
| 1153 | + | |
| 1154 | + | |
| 1155 | + | |
| 1156 | + | |
1145 | 1157 | | |
1146 | 1158 | | |
1147 | 1159 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1955 | 1955 | | |
1956 | 1956 | | |
1957 | 1957 | | |
| 1958 | + | |
| 1959 | + | |
| 1960 | + | |
| 1961 | + | |
| 1962 | + | |
| 1963 | + | |
| 1964 | + | |
| 1965 | + | |
| 1966 | + | |
1958 | 1967 | | |
1959 | 1968 | | |
1960 | 1969 | | |
| |||
1982 | 1991 | | |
1983 | 1992 | | |
1984 | 1993 | | |
1985 | | - | |
| 1994 | + | |
1986 | 1995 | | |
| 1996 | + | |
1987 | 1997 | | |
1988 | 1998 | | |
1989 | 1999 | | |
| |||
2014 | 2024 | | |
2015 | 2025 | | |
2016 | 2026 | | |
2017 | | - | |
| 2027 | + | |
2018 | 2028 | | |
| 2029 | + | |
2019 | 2030 | | |
2020 | 2031 | | |
2021 | 2032 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
313 | 313 | | |
314 | 314 | | |
315 | 315 | | |
316 | | - | |
317 | | - | |
| 316 | + | |
| 317 | + | |
318 | 318 | | |
319 | 319 | | |
320 | 320 | | |
| |||
1025 | 1025 | | |
1026 | 1026 | | |
1027 | 1027 | | |
1028 | | - | |
| 1028 | + | |
1029 | 1029 | | |
1030 | 1030 | | |
1031 | 1031 | | |
| |||
0 commit comments