diff --git a/ets2panda/test/ast/parser/ts/deleting_local_var.ts b/ets2panda/test/ast/parser/ts/deleting_local_var.ts new file mode 100644 index 0000000000000000000000000000000000000000..b132d6f719a99af049d11e614ad81dcb79b14219 --- /dev/null +++ b/ets2panda/test/ast/parser/ts/deleting_local_var.ts @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +let x = 42; +delete x; + +/* @@? 17:9 Error SyntaxError: Deleting local variable in strict mode. */ diff --git a/ets2panda/test/ast/parser/ts/regex_class_range_out_of_order.ts b/ets2panda/test/ast/parser/ts/regex_class_range_out_of_order.ts new file mode 100644 index 0000000000000000000000000000000000000000..66ced1f7e3ec8325be3612bfc3b35c9cf8d8a3b4 --- /dev/null +++ b/ets2panda/test/ast/parser/ts/regex_class_range_out_of_order.ts @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +const regex = /[z-a]/ + +/* @@? 16:16 Error SyntaxError: Class range out of order. */ diff --git a/ets2panda/test/ast/parser/ts/regex_invalid_assertion.ts b/ets2panda/test/ast/parser/ts/regex_invalid_assertion.ts new file mode 100644 index 0000000000000000000000000000000000000000..5ecc52e41b6f07845832f465e890e110ca9ef8da --- /dev/null +++ b/ets2panda/test/ast/parser/ts/regex_invalid_assertion.ts @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +const regex = /(?!/ + +/* @@? 16:16 Error SyntaxError: Invalid assertion. */ diff --git a/ets2panda/test/ast/parser/ts/regex_invalid_char.ts b/ets2panda/test/ast/parser/ts/regex_invalid_char.ts new file mode 100644 index 0000000000000000000000000000000000000000..67a3d115be1da1c8be590b2ae697129a89e6e046 --- /dev/null +++ b/ets2panda/test/ast/parser/ts/regex_invalid_char.ts @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +const regex = /?abc/; + +/* @@? 16:16 Error SyntaxError: Invalid character. */ diff --git a/ets2panda/test/ast/parser/ts/regex_invalid_closing_parenthesis.ts b/ets2panda/test/ast/parser/ts/regex_invalid_closing_parenthesis.ts new file mode 100644 index 0000000000000000000000000000000000000000..41a168aef7a7f84a191e68e83ad6d12bcaa0b8f2 --- /dev/null +++ b/ets2panda/test/ast/parser/ts/regex_invalid_closing_parenthesis.ts @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +const regex = /abc)/; + +/* @@? 16:16 Error SyntaxError: Invalid closing parenthesis. */ diff --git a/ets2panda/test/ast/parser/ts/regex_invalid_non_capturing_group.ts b/ets2panda/test/ast/parser/ts/regex_invalid_non_capturing_group.ts new file mode 100644 index 0000000000000000000000000000000000000000..ee8fbc1596d485fd31b3f582a382c9b2b4075303 --- /dev/null +++ b/ets2panda/test/ast/parser/ts/regex_invalid_non_capturing_group.ts @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +const regex = /(?:abc/; + +/* @@? 16:16 Error SyntaxError: Invalid non-capturing group. */ diff --git a/ets2panda/test/ast/parser/ts/regex_quantifier_ranege.ts b/ets2panda/test/ast/parser/ts/regex_quantifier_ranege.ts new file mode 100644 index 0000000000000000000000000000000000000000..905c66a3e789ac27d7678e6c01239006826483aa --- /dev/null +++ b/ets2panda/test/ast/parser/ts/regex_quantifier_ranege.ts @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +const regex = /a{3,2}/; + +/* @@? 16:16 Error SyntaxError: Quantifier range out of order. */ diff --git a/ets2panda/test/ast/parser/ts/unterminated_multi_line_comment.ts b/ets2panda/test/ast/parser/ts/unterminated_multi_line_comment.ts new file mode 100644 index 0000000000000000000000000000000000000000..d56d6fd4f93157529e3dafeb12a72fecdd93df9f --- /dev/null +++ b/ets2panda/test/ast/parser/ts/unterminated_multi_line_comment.ts @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* @@? 1:1 Error SyntaxError: Unterminated multi-line comment. */ + +/* diff --git a/ets2panda/util/diagnostic/syntax.yaml b/ets2panda/util/diagnostic/syntax.yaml index 6ceffd61d75754163aecf4eeb1110c15ddf32d46..74ca8223a83de14e2d4d9ee8184e8048f09c0267 100644 --- a/ets2panda/util/diagnostic/syntax.yaml +++ b/ets2panda/util/diagnostic/syntax.yaml @@ -626,10 +626,6 @@ syntax: id: 266 message: "Invalid digit." -- name: INVALID_ENUM_TYPE - id: 35 - message: "Invalid enum initialization type." - - name: INVALID_ESCAPE id: 87 message: "Invalid escape." @@ -1323,6 +1319,7 @@ syntax: graveyard: - 29 +- 35 - 37 - 41 - 74