Skip to content

Commit

Permalink
fix: ios crashes on $ in variable names (#165)
Browse files Browse the repository at this point in the history
  • Loading branch information
sargunv authored Dec 22, 2024
1 parent 8cea56b commit 90c1902
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,9 @@ public object ExpressionsDsl {
public val Expression<FloatValue>.em: Expression<TextUnitValue>
get() = this.cast<TextUnitValue>() * emMultiplierVar.use()

internal val spMultiplierVar = Variable<FloatValue>("\$sp_multiplier")
internal val emMultiplierVar = Variable<FloatValue>("\$em_multiplier")
internal val unspecifiedValueVar = Variable<TextUnitValue>("\$unspecified_value")
internal val spMultiplierVar = Variable<FloatValue>("__sp_multiplier")
internal val emMultiplierVar = Variable<FloatValue>("__em_multiplier")
internal val unspecifiedValueVar = Variable<TextUnitValue>("__unspecified_value")

internal fun Expression<*>.resolveTextUnits(
spMultiplier: Expression<FloatValue>,
Expand All @@ -199,14 +199,14 @@ public object ExpressionsDsl {
* }
* ```
*
* Variable names starting with `$` are reserved.
* Variable names starting with `__` are reserved for internal use by the library.
*/
public inline fun <V : ExpressionValue, R : ExpressionValue> withVariable(
name: String,
value: Expression<V>,
block: (Variable<V>) -> Expression<R>,
): Expression<R> {
require(!name.startsWith("\$")) { "Variable names starting with '\$' are reserved." }
require(!name.startsWith("__")) { "Variable names starting with '__' are reserved." }
return Variable<V>(name).let { it.bind(value, block(it)) }
}

Expand Down

0 comments on commit 90c1902

Please sign in to comment.