-
Notifications
You must be signed in to change notification settings - Fork 196
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(compiler): methods on tokenized strings used inflight use lifted …
…non evaluated string (#5766) See #4292. We now special case access to phase independent properties of string objects. Such properties will get the phase of the execution environment so when used inflight we'll use the evaluated tokenized string. ## Checklist - [x] Title matches [Winglang's style guide](https://www.winglang.io/contributing/start-here/pull_requests#how-are-pull-request-titles-formatted) - [x] Description explains motivation and solution - [x] Tests added (always) - [ ] Docs updated (only required for features) - [ ] Added `pr/e2e-full` label if this feature requires end-to-end testing *By submitting this pull request, I confirm that my contribution is made under the terms of the [Wing Cloud Contribution License](https://github.com/winglang/wing/blob/main/CONTRIBUTION_LICENSE.md)*.
- Loading branch information
1 parent
f5b5e3e
commit 745df1e
Showing
11 changed files
with
280 additions
and
48 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
examples/tests/valid/phase_independent_method_on_string.test.w
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
bring cloud; | ||
bring regex; | ||
|
||
let api = new cloud.Api(); | ||
let url_regex = "https?:\\/\\/(www\\.)?[-a-zA-Z0-9@:%._\\+~#=]\{1,256\}\\.[a-zA-Z0-9()]\{1,6\}\\b([-a-zA-Z0-9()@:%_\\+.~#?&//=]*)"; | ||
|
||
// Verify the url is not a valid url (because it's a token) | ||
assert(!regex.match(url_regex, api.url)); | ||
|
||
let token_len = api.url.length; | ||
|
||
|
||
test "phase independent method on string evaluated inflight" { | ||
// Make sure api.url isn't a token but evaled inflight | ||
assert(regex.match(url_regex, api.url)); | ||
|
||
// Call a method on the url (should be called inflight) | ||
assert(api.url.startsWith("http")); | ||
|
||
// Call the length property (should be called inflight) and make sure it's different than the preflight length | ||
assert(api.url.length != token_len); | ||
} |
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
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
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
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
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
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
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
Oops, something went wrong.