Skip to content
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

fix: Introduce escaping some special chars in SCEX typed vars #64

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

mikegpl
Copy link

@mikegpl mikegpl commented Feb 12, 2025

Previously, commonly used chars like , @, ", would cause SCEX compilation errors if used in typed var names. These errors happened due to inconsistency in how typed variables and their types are defined in CodeGeneration macros.

There are still some special chars like \n or ` that will break the macros generating the code for typed vars, but they might be less of a problem if they are publicly announced via TypedVariables.IllegalCharsInVarName. Without such public declaration the responsibility for validating the names is shifted towards the end application, while it isn't the one to impose the restrictions and throw compilation error.

Previously, commonly used chars like space, @, ", would cause SCEX compilation errors if used in typed var names. These errors happened due to inconsistency in how typed variables and their types are defined in CodeGeneration macros.

There are still some special chars like \n or ` that will break the macros generating the code for typed vars, but they might be less of a problem if they are publicly announced via TypedVariables.IllegalCharsInVarName. Without such public declaration the responsibility for validating the names is shifted towards the end application, while it isn't the one to impose the restrictions and throw compilation error.
@sebaciv sebaciv assigned mikegpl and unassigned sebaciv Feb 12, 2025
@mikegpl mikegpl assigned sebaciv and unassigned mikegpl Feb 12, 2025
Comment on lines +68 to +82
private def initContextWithTypedVariable(
variableName: String,
value: Double
): SimpleContext[Unit] = {
val ctx = SimpleContext(())
ctx.setTypedVariable(variableName, value)
ctx
}

private def compileExpression(
expr: String,
variableName: String,
acl: List[MemberAccessSpec] = PredefinedAccessSpecs.basicOperations
): Expression[SimpleContext[Unit], Double] =
compiler.buildExpression
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eh, there is no proper formatter config commited, please reformat it manually to be consistent with other files (2 space indentation)

@sebaciv sebaciv assigned mikegpl and unassigned sebaciv Feb 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants