Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow var to have multiple declarations #2

Merged
merged 9 commits into from
Aug 1, 2023
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[
{
"pos": 122,
"message": "Subsequent variable declarations must have the same type. Variable 's3' must be of type 'number', but here has type 'string'."
},
{
"pos": 168,
"message": "Subsequent variable declarations must have the same type. Variable 's4' must be of type 'string', but here has type 'number'."
},
{
"pos": 222,
"message": "Cannot assign initialiser of type 'number' to variable with declared type 'string'."
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"var s = 'test';\nvar s1 = 'test';\nvar s2 = 'test';\nvar s2 = 'test';\nvar s3 = 2;\nvar s3 = 'test';\nvar s4 = 'test';\nvar s4 = 2;\nvar s4 = 'test';\nvar s5 = 'test';\nvar s5 = 2;\n"
Original file line number Diff line number Diff line change
@@ -0,0 +1,314 @@
{
"locals": {
"s": [
{
"kind": "VariableDeclaration",
"pos": 15
}
],
"s1": [
{
"kind": "VariableDeclaration",
"pos": 41
}
],
"s2": [
{
"kind": "VariableDeclaration",
"pos": 59
},
{
"kind": "VariableDeclaration",
"pos": 84
}
],
"s3": [
{
"kind": "VariableDeclaration",
"pos": 105
},
{
"kind": "VariableDeclaration",
"pos": 122
}
],
"s4": [
{
"kind": "VariableDeclaration",
"pos": 148
},
{
"kind": "VariableDeclaration",
"pos": 168
},
{
"kind": "VariableDeclaration",
"pos": 185
}
],
"s5": [
{
"kind": "VariableDeclaration",
"pos": 203
},
{
"kind": "VariableDeclaration",
"pos": 223
}
]
},
"statements": [
{
"kind": "VariableStatement",
"declarationList": {
"kind": "VariableDeclarationList",
"declarations": {
"0": {
"kind": "VariableDeclaration",
"name": {
"kind": "Identifier",
"text": "s"
},
"init": {
"kind": "StringLiteral",
"value": "test",
"isSingleQuote": true
}
}
},
"flags": 0
}
},
{
"kind": "VariableStatement",
"declarationList": {
"kind": "VariableDeclarationList",
"declarations": {
"0": {
"kind": "VariableDeclaration",
"name": {
"kind": "Identifier",
"text": "s1"
},
"typename": {
"kind": "Identifier",
"text": "string"
},
"init": {
"kind": "StringLiteral",
"value": "test",
"isSingleQuote": true
}
}
},
"flags": 0
}
},
{
"kind": "VariableStatement",
"declarationList": {
"kind": "VariableDeclarationList",
"declarations": {
"0": {
"kind": "VariableDeclaration",
"name": {
"kind": "Identifier",
"text": "s2"
},
"init": {
"kind": "StringLiteral",
"value": "test",
"isSingleQuote": true
}
}
},
"flags": 0
}
},
{
"kind": "VariableStatement",
"declarationList": {
"kind": "VariableDeclarationList",
"declarations": {
"0": {
"kind": "VariableDeclaration",
"name": {
"kind": "Identifier",
"text": "s2"
},
"typename": {
"kind": "Identifier",
"text": "string"
},
"init": {
"kind": "StringLiteral",
"value": "test",
"isSingleQuote": true
}
}
},
"flags": 0
}
},
{
"kind": "VariableStatement",
"declarationList": {
"kind": "VariableDeclarationList",
"declarations": {
"0": {
"kind": "VariableDeclaration",
"name": {
"kind": "Identifier",
"text": "s3"
},
"typename": {
"kind": "Identifier",
"text": "number"
},
"init": {
"kind": "NumericLiteral",
"value": 2
}
}
},
"flags": 0
}
},
{
"kind": "VariableStatement",
"declarationList": {
"kind": "VariableDeclarationList",
"declarations": {
"0": {
"kind": "VariableDeclaration",
"name": {
"kind": "Identifier",
"text": "s3"
},
"init": {
"kind": "StringLiteral",
"value": "test",
"isSingleQuote": true
}
}
},
"flags": 0
}
},
{
"kind": "VariableStatement",
"declarationList": {
"kind": "VariableDeclarationList",
"declarations": {
"0": {
"kind": "VariableDeclaration",
"name": {
"kind": "Identifier",
"text": "s4"
},
"typename": {
"kind": "Identifier",
"text": "string"
},
"init": {
"kind": "StringLiteral",
"value": "test",
"isSingleQuote": true
}
}
},
"flags": 0
}
},
{
"kind": "VariableStatement",
"declarationList": {
"kind": "VariableDeclarationList",
"declarations": {
"0": {
"kind": "VariableDeclaration",
"name": {
"kind": "Identifier",
"text": "s4"
},
"typename": {
"kind": "Identifier",
"text": "number"
},
"init": {
"kind": "NumericLiteral",
"value": 2
}
}
},
"flags": 0
}
},
{
"kind": "VariableStatement",
"declarationList": {
"kind": "VariableDeclarationList",
"declarations": {
"0": {
"kind": "VariableDeclaration",
"name": {
"kind": "Identifier",
"text": "s4"
},
"init": {
"kind": "StringLiteral",
"value": "test",
"isSingleQuote": true
}
}
},
"flags": 0
}
},
{
"kind": "VariableStatement",
"declarationList": {
"kind": "VariableDeclarationList",
"declarations": {
"0": {
"kind": "VariableDeclaration",
"name": {
"kind": "Identifier",
"text": "s5"
},
"init": {
"kind": "StringLiteral",
"value": "test",
"isSingleQuote": true
}
}
},
"flags": 0
}
},
{
"kind": "VariableStatement",
"declarationList": {
"kind": "VariableDeclarationList",
"declarations": {
"0": {
"kind": "VariableDeclaration",
"name": {
"kind": "Identifier",
"text": "s5"
},
"typename": {
"kind": "Identifier",
"text": "string"
},
"init": {
"kind": "NumericLiteral",
"value": 2
}
}
},
"flags": 0
}
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"var var1 = 'test';\nvar var1 = 'var';\nvar var1 = 'no type annotation needed';\n"
Loading