-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for member projection syntax
Cls::mem
- Loading branch information
Showing
48 changed files
with
350 additions
and
79 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
:js | ||
:todo | ||
|
||
|
||
print of | ||
let x = 1 | ||
x + 1 | ||
//│ ╔══[ERROR] Expected a body for let bindings in expression position | ||
//│ ║ l.6: let x = 1 | ||
//│ ╙── ^^^^^ | ||
//│ ╔══[ERROR] Name not found: x | ||
//│ ║ l.7: x + 1 | ||
//│ ╙── ^ | ||
//│ = 1 | ||
|
||
print of | ||
open Predef | ||
let x = 1 | ||
x + 1 | ||
//│ ╔══[ERROR] Illegal position for 'open' statement. | ||
//│ ║ l.17: open Predef | ||
//│ ╙── ^^^^^^ | ||
//│ ╔══[ERROR] Expected a body for let bindings in expression position | ||
//│ ║ l.18: let x = 1 | ||
//│ ╙── ^^^^^ | ||
//│ ╔══[ERROR] Name not found: x | ||
//│ ║ l.19: x + 1 | ||
//│ ╙── ^ | ||
|
||
|
64 changes: 64 additions & 0 deletions
64
hkmc2/shared/src/test/mlscript/basics/BadMemberProjections.mls
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,64 @@ | ||
:js | ||
|
||
|
||
:sjs | ||
:e | ||
1::x | ||
//│ ╔══[ERROR] Integer literal is not a known class. | ||
//│ ║ l.6: 1::x | ||
//│ ║ ^ | ||
//│ ╟── Note: any expression of the form `‹expression›::‹identifier›` is a member projection; | ||
//│ ╙── add a space before ‹identifier› to make it an operator application. | ||
//│ JS (unsanitized): | ||
//│ (self, ...args) => { return self.x(...args) ?? null; } | ||
//│ = [Function (anonymous)] | ||
|
||
:ssjs | ||
:e | ||
:re | ||
1::x() | ||
//│ ╔══[ERROR] Integer literal is not a known class. | ||
//│ ║ l.19: 1::x() | ||
//│ ║ ^ | ||
//│ ╟── Note: any expression of the form `‹expression›::‹identifier›` is a member projection; | ||
//│ ╙── add a space before ‹identifier› to make it an operator application. | ||
//│ JS: | ||
//│ ((...args1) => { | ||
//│ globalThis.Predef.checkArgs("", 1, false, args1.length); | ||
//│ let self = args1[0]; | ||
//│ let args = globalThis.Predef.tupleSlice(args1, 1, 0); | ||
//│ return self.x(...args) ?? null; | ||
//│ })() | ||
//│ ═══[RUNTIME ERROR] Error: Function expected 1 arguments but got 0 | ||
|
||
|
||
fun (::) f(a, b) = [a, b] | ||
|
||
let x = 1 | ||
//│ x = 1 | ||
|
||
"A" :: x | ||
//│ = [ 'A', 1 ] | ||
|
||
"A":: x | ||
//│ = [ 'A', 1 ] | ||
|
||
:e | ||
"A"::x | ||
//│ ╔══[ERROR] String literal is not a known class. | ||
//│ ║ l.47: "A"::x | ||
//│ ║ ^^^ | ||
//│ ╟── Note: any expression of the form `‹expression›::‹identifier›` is a member projection; | ||
//│ ╙── add a space before ‹identifier› to make it an operator application. | ||
//│ = [Function (anonymous)] | ||
|
||
:e | ||
"A" ::x | ||
//│ ╔══[ERROR] String literal is not a known class. | ||
//│ ║ l.56: "A" ::x | ||
//│ ║ ^^^ | ||
//│ ╟── Note: any expression of the form `‹expression›::‹identifier›` is a member projection; | ||
//│ ╙── add a space before ‹identifier› to make it an operator application. | ||
//│ = [Function (anonymous)] | ||
|
||
|
Oops, something went wrong.