Atlassian uses cookies to improve your browsing experience, perform analytics and research, and conduct advertising. Accept all cookies to indicate that you agree to our use of cookies on your device. Atlassian cookies and tracking notice, (opens new window)
context.getDefaultAssignmentScope() is now being used too often
Description
context.getDefaultAssignmentScope() was only supposed to be used as the default scope argument to the scopeFindNearby() method when assigning a variable that may not exist or safely looking up an unscope variable on the left had hand side of the elvis operator or safe navigation operator. The goal was never to replace ALL instance of variablesScope with this.
@maurizio.taverna I have updated a bunch of test which had incorrect expected values for transpiled java source, mostly related to accessing explicitly scoped variables. Many of these tests I had already reviewed a few weeks back to ensure they had the correct expected values, but they were recently changed to have an incorrection assertion, which made them pass when they should have been failing!
But the original assertion was correct and the test should not be passing. If you think any of the expected values are incorrect in the test assertions, please ask first so we can discuss before we change the tests again.
Brad WoodNovember 6, 2023 at 8:55 PM
Note, it’s ok to use a variablesScope reference if the scope reference has already been obtained above, but keep in mind not all scopes exist in all contexts.
Fixed
Pinned fields
Click on the next to a field label to start pinning.
context.getDefaultAssignmentScope()
was only supposed to be used as the default scope argument to the scopeFindNearby() method when assigning a variable that may not exist or safely looking up an unscope variable on the left had hand side of the elvis operator or safe navigation operator. The goal was never to replace ALL instance ofvariablesScope
with this.Now code such as
variables.foo
is transpiling to
context.getDefaultAssignmentScope().dereference(Key.of("foo"), false)
but this is not correct. In the event that the BoxLang code has an explicit scope in the code, then the transpiled Java code should use
content.getScopeNearby( WhateverScope.name )
in order to get that explicit scope.