-
Notifications
You must be signed in to change notification settings - Fork 5
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
mikegpl
wants to merge
2
commits into
master
Choose a base branch
from
fix/varname-special-chars
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
mikegpl
commented
Feb 12, 2025
scex-core/src/main/scala/com/avsystem/scex/compiler/CodeGeneration.scala
Show resolved
Hide resolved
sebaciv
requested changes
Feb 12, 2025
scex-core/src/test/scala/com/avsystem/scex/compiler/JavaScexCompilerTest.scala
Outdated
Show resolved
Hide resolved
scex-core/src/test/scala/com/avsystem/scex/compiler/JavaScexCompilerTest.scala
Outdated
Show resolved
Hide resolved
scex-core/src/main/scala/com/avsystem/scex/compiler/CodeGeneration.scala
Show resolved
Hide resolved
scex-core/src/test/scala/com/avsystem/scex/compiler/JavaScexCompilerTest.scala
Outdated
Show resolved
Hide resolved
sebaciv
reviewed
Feb 13, 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 |
There was a problem hiding this comment.
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)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 inCodeGeneration
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 viaTypedVariables.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.