File tree 2 files changed +24
-3
lines changed
2 files changed +24
-3
lines changed Original file line number Diff line number Diff line change @@ -9,10 +9,12 @@ class LET {
9
9
run ( scope ) {
10
10
const name = this . name ;
11
11
12
- const instance = scope . retrieveGraph ( this . name . first ) ;
12
+ if ( this . reassign ) {
13
+ const instance = scope . retrieveGraph ( this . name . first ) ;
13
14
14
- if ( instance ?. constant ) {
15
- throw TypeError ( "Assignment to constant variable." ) ;
15
+ if ( instance ?. constant ) {
16
+ throw TypeError ( "Assignment to constant variable." ) ;
17
+ }
16
18
}
17
19
18
20
const evaluation = this . value . run ( scope , false , false ) ;
Original file line number Diff line number Diff line change @@ -1117,6 +1117,25 @@ describe("Nucleoid", () => {
1117
1117
equal ( nucleoid . run ( "trade1.worth" ) , 100 ) ;
1118
1118
} ) ;
1119
1119
1120
+ it ( "assigns let statement after const statement with the same name" , ( ) => {
1121
+ const result = nucleoid . run (
1122
+ `
1123
+ const barcode = "barcode";
1124
+ {
1125
+ let barcode = "barcode";
1126
+ {
1127
+ barcode = "barcode2";
1128
+ {
1129
+ return barcode;
1130
+ }
1131
+ }
1132
+ }
1133
+ `
1134
+ ) ;
1135
+
1136
+ equal ( result , "barcode2" ) ;
1137
+ } ) ;
1138
+
1120
1139
it ( "holds result of function in let" , ( ) => {
1121
1140
nucleoid . run ( "bugs = [ ]" ) ;
1122
1141
nucleoid . run ( "ticket = 1" ) ;
You can’t perform that action at this time.
0 commit comments