Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into appearance_name_d…
Browse files Browse the repository at this point in the history
…esc_copying
  • Loading branch information
TobleroneSwordfish committed Dec 18, 2024
2 parents 1a362a1 + 2e5ad95 commit 6862009
Show file tree
Hide file tree
Showing 38 changed files with 431 additions and 124 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ name: Lint
on:
pull_request:
branches: [master]
types: [opened, synchronize, reopened, ready_for_review]

jobs:
lint:
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest

steps:
Expand Down
16 changes: 16 additions & 0 deletions Content.IntegrationTests/DMProject/Tests/filter_initial.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/obj/blurry
filters = filter(type="blur", size=2)

/obj/veryblurry
filters = list(type="blur", size=4)

/obj/notatallblurry
filters = list()

/proc/test_filter_init()
var/obj/veryblurry/VB = new()
ASSERT(length(VB.filters) == 1)
var/obj/blurry/B = new()
ASSERT(length(B.filters) == 1)
var/obj/notatallblurry/NAB = new()
ASSERT(length(NAB.filters) == 0)
1 change: 1 addition & 0 deletions Content.IntegrationTests/DMProject/code.dm
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,5 @@
test_range()
test_verb_duplicate()
test_appearance()
test_filter_init()
world.log << "IntegrationTests successful, /world/New() exiting..."
1 change: 1 addition & 0 deletions Content.IntegrationTests/DMProject/environment.dme
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
#include "Tests/color_matrix.dm"
#include "Tests/range.dm"
#include "Tests/verb_duplicate.dm"
#include "Tests/filter_initial.dm"
#include "map.dmm"
#include "interface.dmf"

This file was deleted.

6 changes: 0 additions & 6 deletions Content.Tests/DMProject/Broken Tests/Procs/Arglist/initial.dm

This file was deleted.

7 changes: 5 additions & 2 deletions Content.Tests/DMProject/Tests/Builtins/__IMPLIED_TYPE__.dm
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@


/datum/test/var/bar = "foobar"
/datum/test
/proc/RunTest()
var/datum/test/D = __IMPLIED_TYPE__
ASSERT(D.bar == "foobar")
ASSERT(D == /datum/test)
D = ArgumentTest(__IMPLIED_TYPE__)

/proc/ArgumentTest(some_argument)
ASSERT(some_argument == /datum/test)
11 changes: 11 additions & 0 deletions Content.Tests/DMProject/Tests/Expression/proccall_keyword_param.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

//# issue 655
//# issue 265

/datum/proc/nullproc(null, temp)
ASSERT(isnull(null))
ASSERT(temp == 2)

/proc/RunTest()
var/datum/D = new
D.nullproc(1,2)
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// RUNTIME ERROR

/proc/ListNullArg2(a[5][3])
ASSERT(a[1].len == 3)
ASSERT(a[1].len == 3) // a should be null

/proc/RunTest()
ListNullArg2()
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// RUNTIME ERROR

/proc/ListNullArg1(a[5])
ASSERT(a.len == 5)
ASSERT(a.len == 5) // a should be null

/proc/RunTest()
ListNullArg1()
6 changes: 6 additions & 0 deletions Content.Tests/DMProject/Tests/Procs/Arglist/initial.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

/proc/_initial(...)
ASSERT(initial(arglist(args))[1] == "foo")

/proc/RunTest()
_initial("foo")
20 changes: 20 additions & 0 deletions Content.Tests/DMProject/Tests/Regex/regex_find_replace.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
var/models = "/obj/cable/brown{\n\ticon_state = \"2-8\"\n\t},\n/obj/cable/brown{\n\ticon_state = \"4-8\"\n\t},\n/turf/simulated/floor/orangeblack,\n/area/station/devzone"
var/result_match = "/obj/cable/brown{\n\ticon_state = \"1\"\n\t},\n/obj/cable/brown{\n\ticon_state = \"2\"\n\t},\n/turf/simulated/floor/orangeblack,\n/area/station/devzone"

/proc/RunTest()
var/list/originalStrings = list()
var/regex/noStrings = regex(@{"(["])(?:(?=(\\?))\2(.|\n))*?\1"})
var/stringIndex = 1
var/found
do
found = noStrings.Find(models, noStrings.next)
if(found)
var indexText = {""[stringIndex]""}
stringIndex++
var match = copytext(noStrings.match, 2, -1) // Strip quotes
models = noStrings.Replace(models, indexText, found)
originalStrings[indexText] = (match)
while(found)
ASSERT(models == result_match)
ASSERT(originalStrings ~= list("\"1\"" = "2-8", "\"2\"" = "4-8"))
ASSERT(stringIndex == 3)
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// COMPILE ERROR
// COMPILE ERROR OD0501

/datum
var/const/idx = 0
Expand Down
18 changes: 18 additions & 0 deletions Content.Tests/DMProject/Tests/Statements/For/reuse_decl_const2.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// COMPILE ERROR OD0501

/datum
var/const/idx = 0
var/c = 0
proc/do_loop()
for (idx in list(1,2,3))
c += idx

/proc/RunTest()
var/datum/d = new
d.do_loop()

var/const/idx = 0
var/c = 0
for (idx in list(1,2,3))
c += idx

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// COMPILE ERROR OD3205
#pragma ExtraToken error

/proc/RunTest()
if(1).
ASSERT(TRUE)
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,7 @@
ASSERT(TRUE)
else
ASSERT(FALSE)
for(var/i in 1 to 1):
ASSERT(TRUE)
for(var/i in 1 to 1).
ASSERT(TRUE)
2 changes: 2 additions & 0 deletions DMCompiler/Bytecode/DreamProcOpcode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,8 @@ public enum DreamProcOpcode : byte {
ReturnReferenceValue = 0x97,
[OpcodeMetadata(0, OpcodeArgType.Float)]
ReturnFloat = 0x98,
[OpcodeMetadata(1, OpcodeArgType.Reference, OpcodeArgType.String)]
IndexRefWithString = 0x99,
}
// ReSharper restore MissingBlankLines

Expand Down
1 change: 1 addition & 0 deletions DMCompiler/Compiler/CompilerError.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ public enum WarningCode {
AssignmentInConditional = 3202,
PickWeightedSyntax = 3203,
AmbiguousInOrder = 3204,
ExtraToken = 3205,
RuntimeSearchOperator = 3300,

// 4000 - 4999 are reserved for runtime configuration. (TODO: Runtime doesn't know about configs yet!)
Expand Down
42 changes: 39 additions & 3 deletions DMCompiler/Compiler/DM/DMParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1125,8 +1125,10 @@ private DMASTProcStatementIf If() {

BracketWhitespace();
ConsumeRightParenthesis();
Whitespace();
Check(TokenType.DM_Colon);
if (Check(TokenType.DM_Colon) || Check(TokenType.DM_Period)) {
Emit(WarningCode.ExtraToken, loc, "Extra token at end of proc statement");
}

Whitespace();

DMASTProcStatement? procStatement = ProcStatement();
Expand Down Expand Up @@ -1165,6 +1167,10 @@ private DMASTProcStatement For() {
Whitespace();

if (Check(TokenType.DM_RightParenthesis)) {
if (Check(TokenType.DM_Colon) || Check(TokenType.DM_Period)) {
Emit(WarningCode.ExtraToken, loc, "Extra token at end of proc statement");
}

return new DMASTProcStatementInfLoop(loc, GetForBody(loc));
}

Expand All @@ -1185,6 +1191,10 @@ private DMASTProcStatement For() {
if (expr1 is DMASTAssign assign) {
ExpressionTo(out var endRange, out var step);
Consume(TokenType.DM_RightParenthesis, "Expected ')' in for after to expression");
if (Check(TokenType.DM_Colon) || Check(TokenType.DM_Period)) {
Emit(WarningCode.ExtraToken, loc, "Extra token at end of proc statement");
}

return new DMASTProcStatementFor(loc, new DMASTExpressionInRange(loc, assign.LHS, assign.RHS, endRange, step), null, null, dmTypes, GetForBody(loc));
} else {
Emit(WarningCode.BadExpression, "Expected = before to in for");
Expand All @@ -1197,15 +1207,27 @@ private DMASTProcStatement For() {
DMASTExpression? listExpr = Expression();
Whitespace();
Consume(TokenType.DM_RightParenthesis, "Expected ')' in for after expression 2");
if (Check(TokenType.DM_Colon) || Check(TokenType.DM_Period)) {
Emit(WarningCode.ExtraToken, loc, "Extra token at end of proc statement");
}

return new DMASTProcStatementFor(loc, new DMASTExpressionIn(loc, expr1, listExpr), null, null, dmTypes, GetForBody(loc));
}

if (!Check(ForSeparatorTypes)) {
Consume(TokenType.DM_RightParenthesis, "Expected ')' in for after expression 1");
if (Check(TokenType.DM_Colon) || Check(TokenType.DM_Period)) {
Emit(WarningCode.ExtraToken, loc, "Extra token at end of proc statement");
}

return new DMASTProcStatementFor(loc, expr1, null, null, dmTypes, GetForBody(loc));
}

if (Check(TokenType.DM_RightParenthesis)) {
if (Check(TokenType.DM_Colon) || Check(TokenType.DM_Period)) {
Emit(WarningCode.ExtraToken, loc, "Extra token at end of proc statement");
}

return new DMASTProcStatementFor(loc, expr1, null, null, dmTypes, GetForBody(loc));
}

Expand All @@ -1221,10 +1243,18 @@ private DMASTProcStatement For() {

if (!Check(ForSeparatorTypes)) {
Consume(TokenType.DM_RightParenthesis, "Expected ')' in for after expression 2");
if (Check(TokenType.DM_Colon) || Check(TokenType.DM_Period)) {
Emit(WarningCode.ExtraToken, loc, "Extra token at end of proc statement");
}

return new DMASTProcStatementFor(loc, expr1, expr2, null, dmTypes, GetForBody(loc));
}

if (Check(TokenType.DM_RightParenthesis)) {
if (Check(TokenType.DM_Colon) || Check(TokenType.DM_Period)) {
Emit(WarningCode.ExtraToken, loc, "Extra token at end of proc statement");
}

return new DMASTProcStatementFor(loc, expr1, expr2, null, dmTypes, GetForBody(loc));
}

Expand All @@ -1239,6 +1269,10 @@ private DMASTProcStatement For() {
}

Consume(TokenType.DM_RightParenthesis, "Expected ')' in for after expression 3");
if (Check(TokenType.DM_Colon) || Check(TokenType.DM_Period)) {
Emit(WarningCode.ExtraToken, loc, "Extra token at end of proc statement");
}

return new DMASTProcStatementFor(loc, expr1, expr2, expr3, dmTypes, GetForBody(loc));

DMASTProcBlockInner GetForBody(Location forLocation) {
Expand Down Expand Up @@ -1690,7 +1724,9 @@ private List<DMASTDefinitionParameter> DefinitionParameters(out bool wasIndeterm
var loc = Current().Location;
Whitespace();

DMASTExpression? value = PathArray(ref path.Path);
PathArray(ref path.Path);

DMASTExpression? value = null;
DMASTExpression? possibleValues = null;

if (Check(TokenType.DM_DoubleSquareBracketEquals)) {
Expand Down
Loading

0 comments on commit 6862009

Please sign in to comment.