Skip to content

Commit 0daf420

Browse files
committed
Initial implementation of default parameters
1 parent 8f8c336 commit 0daf420

File tree

3 files changed

+4
-8
lines changed

3 files changed

+4
-8
lines changed

src/MoonSharp.Interpreter/Tree/Expressions/IndexExpression.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ class IndexExpression : Expression, IVariable
1010
Expression m_BaseExp;
1111
Expression m_IndexExp;
1212
string m_Name;
13-
private Token nameToken;
1413
private bool inc;
1514
private bool dec;
1615
private bool nilCheck;
@@ -125,7 +124,7 @@ public void CompileAssignment(ByteCode bc, Operator op, int stackofs, int tuplei
125124
{
126125
if (isLength)
127126
{
128-
throw new SyntaxErrorException(nameToken, "Cannot assign to readonly property .length");
127+
throw new SyntaxErrorException(null, "Cannot assign to readonly property .length");
129128
}
130129
if (op != Operator.NotAnOperator)
131130
{

src/MoonSharp.Interpreter/Tree/Lexer/Lexer.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -851,9 +851,7 @@ private Token ReadHashBang(int fromLine, int fromCol)
851851
private Token ReadCMultilineComment(int fromLine, int fromCol)
852852
{
853853
StringBuilder text = new StringBuilder(32);
854-
855-
bool extraneousFound = false;
856-
854+
857855
for (char c = CursorChar(); ; c = CursorCharNext())
858856
{
859857
if (c == '\r') continue;
@@ -894,7 +892,6 @@ private Token ReadComment(int fromLine, int fromCol)
894892
}
895893
else if (c == '\n')
896894
{
897-
extraneousFound = true;
898895
CursorCharNext();
899896
return CreateToken(TokenType.Comment, fromLine, fromCol, text.ToString());
900897
}

src/MoonSharp.Interpreter/Tree/Statements/FunctionDefinitionStatement.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ class FunctionDefinitionStatement : Statement
1111
internal class FunctionParamRef
1212
{
1313
public string Name { get; set; }
14-
public Expression? DefaultValue { get; set; }
14+
public Expression DefaultValue { get; set; }
1515

1616
public FunctionParamRef(string name)
1717
{
1818
Name = name;
1919
}
2020

21-
public FunctionParamRef(string name, Expression? defaultValue)
21+
public FunctionParamRef(string name, Expression defaultValue)
2222
{
2323
Name = name;
2424
DefaultValue = defaultValue;

0 commit comments

Comments
 (0)