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

Compiler crashes when empty method has a return-type from another module #324

Open
IsaacOscar opened this issue Feb 18, 2020 · 1 comment

Comments

@IsaacOscar
Copy link
Contributor

I hade a strange compiler crash, this is the simplest code I could come up with that reproduced it:

In a file Foo.grace:

import "Bar" as Bar
method foo -> Bar.Foo { }

In a file Bar.grace:

type Foo = interface {}

Running mgc Foo.grace produces the following:

minigrace: Foo: 0.56 (+0.56): executing sub-compile of /root/Bar.grace
BoundsError: index 0 but list has size 0
  raised from list.at(_) at /root/minigrace/collections.grace:423
  requested from list.last at /root/minigrace/collections.grace:331
  requested from symbolTableVis.visitCall(_)up(_) at /root/minigrace/identifierresolution.grace:1050
  requested from symbolTableVis.visitMember(_)up(_) at /root/minigrace/identifierresolution.grace:1243
  requested from memberNode.new(_,_).accept(_)from(_) at /root/minigrace/ast.grace:1978
  requested from methodNode.new(_,_,_).accept(_)from(_) at /root/minigrace/ast.grace:1290
  requested from block.apply(_) at /root/minigrace/ast.grace:1617
  requested from block.apply at /root/minigrace/collections.grace:586
  requested from list.while(_)do(_) at intrinsic.grace:111
  requested from list.do(_) at /root/minigrace/collections.grace:582
  requested from moduleNode.body(_).accept(_)from(_) at /root/minigrace/ast.grace:1617
  requested from buildSymbolTableFor(_)ancestors(_) at /root/minigrace/identifierresolution.grace:1300
  requested from resolve(_) at /root/minigrace/identifierresolution.grace:1634
  requested from block.apply at /root/minigrace/compiler.grace:77
  requested from compileInputFile at /root/minigrace/compiler.grace:23
  requested from module initialization at /root/minigrace/compiler.grace:16
 422:         method at(n) { 423:             native "js" code ‹var idx = var_n._value; 424:                 var result = this._value[idx-1]
@IsaacOscar
Copy link
Contributor Author

I fixed this by just adding an expression (such as done) within the foo method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant