-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds diagnostic for when a variables type changes (#130)
* Adds diagnostic for when a variables type changes * Some more tests around object type
- Loading branch information
1 parent
7004517
commit 590ccc2
Showing
8 changed files
with
197 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
interface Iface1 | ||
a as string | ||
end interface | ||
|
||
interface Iface2 | ||
a as string | ||
optional b as string | ||
end interface | ||
|
||
interface OtherFace1 | ||
a as integer | ||
end interface | ||
|
||
function convertToIface1(arg as Iface2) as Iface1 | ||
arg = {a: arg.a} ' no diagnostic | ||
return arg | ||
end function | ||
|
||
function convertToIface2(arg as Iface1) as Iface2 | ||
arg = {a: arg.a, b: "hello"} ' no diagnostic | ||
return arg | ||
end function | ||
|
||
function convertToIface2ViaTypeCast(arg as Iface1) | ||
arg = arg as Iface2 ' no diagnostic | ||
return arg | ||
end function | ||
|
||
function convertToToOtherFace1(arg as Iface1) | ||
arg as OtherFace1 = {a: 1} ' diagnostic | ||
return arg | ||
end function | ||
|
||
|
||
class Parent | ||
a as string | ||
end class | ||
|
||
class Child extends Parent | ||
b as string | ||
end class | ||
|
||
function convertToParent(arg as Child) | ||
arg = new Parent() ' diagnostic | ||
return arg | ||
end function | ||
|
||
function convertToChild(arg as Parent) | ||
arg = new Child() ' no diagnostic - Child is a subclass of Parent | ||
return arg | ||
end function |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
sub checkTypesNoProblem(param as string) ' no diagnostic | ||
param = "Hello " + param | ||
num = 1234 | ||
num = 6.7 | ||
bool = true | ||
if num > 3 | ||
bool = false | ||
end if | ||
end sub | ||
|
||
sub checkTypesChangeFromParam(param as string) | ||
param = 1 ' was string. now integer | ||
end sub | ||
|
||
|
||
sub checkTypesInFunc() | ||
value = 1 | ||
value = "hello" ' was string. now integer | ||
end sub | ||
|
||
function getDynamic() | ||
return 1 | ||
end function | ||
|
||
sub checkTypesDefinedToDynamic() | ||
value = 1 | ||
value = getDynamic() ' was integer. now dynamic | ||
end sub | ||
|
||
sub checkTypesNumberChange() ' no diagnostic | ||
param = 1 | ||
param = 3.14 | ||
end sub | ||
|
||
|
||
sub checkTypesDynamicToDefined() ' no diagnostic | ||
value = getDynamic() | ||
value = 1 ' was dynamic. now integer | ||
end sub | ||
|
||
sub checkTypesObject(obj as object) | ||
if obj = invalid | ||
obj = createObject("roAssociativeArray") | ||
end if | ||
obj.foo = "bar" | ||
end sub | ||
|
||
sub checkTypesObjectToPrimitive(obj as object) | ||
obj = 3 ' This is allowed because primitive types can be boxed as objects | ||
end sub | ||
|
||
sub checkTypesPrimitiveToObject(obj as integer) | ||
obj = createObject("roAssociativeArray") ' was integer. now associativearray | ||
end sub |