Commit 8886bf78 authored by Sebastian Biewer's avatar Sebastian Biewer
Browse files

Fixes incorrect recursion in type checker

parent 4ed7d2d1
# Change Log for PseuCo Language
## 0.8.4 - 2020-06-03
### Fixed
- Compilers relying on AST method `getType` did not working properly.
## 0.8.3 - 2019-05-31
### Added
......
......@@ -47,9 +47,9 @@ class PCNode
# @ brief Recursive implementation for type checking.
#
###
getType: (env) ->
getType: (args...) ->
if not (@_type?)
@_type = @_getType(env)
@_type = @_getType(args...)
@_type = true if not (@_type?) # remember that we already checked type
if @_type == true then null else @_type
......@@ -610,7 +610,9 @@ class PCDecl extends PCNode
if @type.isEqual(new PCTType(PCTType.MUTEX))
throw ({"line" : @line, "column" : @column, "wholeFile" : false, "name" : "OldSyntax", "message" : "You have used an old syntax. The type named \"mutex\" was renamed to \"lock\". For a complete list of changes look <a href=\"#/help#pseuco-syntax-migration\">here</a>."})
for child in @children[1..]
type = child._getType(env, @type)
type = child.getType(env, @type)
#debugger
#throw ({"line" : @line, "column" : @column, "message" : "WTF is wrong here?"})
if type? and not @type.isEqual(type)
throw ({"line" : @line, "column" : @column, "wholeFile" : false, "name" : "InvalidType", "message" : "You can't initialize variable of type #{@type} with value of type #{type}"})
if @type.getBaseType().isEqual(new PCTType(PCTType.AGENT))
......@@ -669,7 +671,7 @@ class PCVariableDeclarator extends PCNode
###
_getType: (env, targetType) ->
if @children.length > 0
@children[0]._getType(env, targetType)
@children[0].getType(env, targetType)
else
null
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment