Skip to content

bootstrapping w/ new compiler: Merged #233 onto master #241

merged 66 commits into from Jun 16, 2014

2 participants

The Mirah Community member

see #233 for details

baroquebobcat added some commits Jan 5, 2014
@baroquebobcat baroquebobcat prep for 0.1.2 release
- update history
- bump versions from dev/SNAPSHOT
@baroquebobcat baroquebobcat fix up maven release notes fe53788
@baroquebobcat baroquebobcat bump version to 0.1.3 1431331
@baroquebobcat baroquebobcat extract isMacro helper in typer d4626eb
@baroquebobcat baroquebobcat add helper for expanding and replacing macros b38a592
@baroquebobcat baroquebobcat typer formatting ea9d8ea
@baroquebobcat baroquebobcat move debugging module into test_helper 0099f67
@baroquebobcat baroquebobcat fix mirror lub equality assertion d306a89
@baroquebobcat baroquebobcat add pend to test depending on undefined constant 3007c6c
@baroquebobcat baroquebobcat add tmp dir to ignored files 673d9e4
@baroquebobcat baroquebobcat move debugging help to the test helper
turns out that other tests could benefit from being able to do finer logging
@baroquebobcat baroquebobcat break out failing superclass type update mirror test a0053ba
@baroquebobcat baroquebobcat add toString to NarrowingTypeFuture f12196b
@baroquebobcat baroquebobcat move local var def in mirrors base_type closer to usage 99350b3
@baroquebobcat baroquebobcat fix superclass mirror type updates
mirror superclass definition changes were not being propagated because the resolved type was staying the same due to the earlier change I added where MirrorProxies now proxy equals. Now the mirror type explicitly tells the TypeFuture to forget its previous type when updating that type, forcing all listeners to be updated.
@baroquebobcat baroquebobcat change rake deps to dist/mirahc for now + add clean for downloaded deps 67966e0
@baroquebobcat baroquebobcat try fixing travis by fixing file sorting 29d335a
@baroquebobcat baroquebobcat Merge branch 'new_bootstrap' of git:// into ri…

ribrdb commented on d306a89 Feb 11, 2014

Actually the whole point of the proxies is to make sure different versions of a type do not compare as equal in the typer. We should fix the test use isSameType or toString or something like that.

The Mirah Community member


baroquebobcat added some commits Feb 17, 2014
@baroquebobcat baroquebobcat Revert "fix mirror lub equality assertion"
This reverts commit d306a89.

Turns out this is incorrect: d306a89#commitcomment-5345748
@baroquebobcat baroquebobcat change mirror assertion from equality to same type check 1b870c6
@baroquebobcat baroquebobcat use the pend w/ block form so that when ClassPath is added, it'll fail b0bfa37
@baroquebobcat baroquebobcat fix compilation helper s.t. separate compilation test passes 9df5e48
@baroquebobcat baroquebobcat extract diagnostic construction in error collector into helper method 71536e6
@baroquebobcat baroquebobcat improve compile, parse_and_type new backend test helpers
now at 1 failures, 4 errors, 10 pendings instead of 2 failures, 5 errors, 10 pendings. Slightly better
@baroquebobcat baroquebobcat change field setter test so it doesn't depend on ast
it use to depend on mirah.lang.ast, but that's not in the classpath by default
@baroquebobcat baroquebobcat replace System.out.println w/ puts in tests
since the puts macro is back, we should use it in tests instead of System.out.println
@baroquebobcat baroquebobcat rm test that identified broken behavior that's fixed wrt interfaces 8208a27
@baroquebobcat baroquebobcat rm accidentally checked fix for editor that doesn't understand 'EOF' 3422c00
@baroquebobcat baroquebobcat fix annotation value test
fixtures are not added to the classpath anymore, so you can't get at them easily from jruby

additionally, the annotations should use RUNTIME retention to ensure it's accessible.
@baroquebobcat baroquebobcat use CLASS as default retention for annotations 3b3713a
@baroquebobcat baroquebobcat add color toggle to self hosted jar 4f86094
@baroquebobcat baroquebobcat fix c&p'd test case name 3a58e94
@baroquebobcat baroquebobcat extract an object to hold onto MirahTool cfg d884d90
@baroquebobcat baroquebobcat convert class loader tests to point directly at Mirah classes 04a3b08
@baroquebobcat baroquebobcat pull out arg object into its own file 68bef4a
@baroquebobcat baroquebobcat move logger setup to MirahArguments b45d158
@baroquebobcat baroquebobcat only do new_ci and not bytecode_ci 78596fa
@baroquebobcat baroquebobcat rm old backend rake tasks 554860a
@baroquebobcat baroquebobcat oops. fix typo in args code
forgot to run compile.
@baroquebobcat baroquebobcat rm bytecode test helper as it's not needed anymore cfa7c39
@baroquebobcat baroquebobcat rm old generator test f9761b2
@baroquebobcat baroquebobcat rm mirahp
mirahp isn't very interesting. I'd like to have some debug tools, but it's not it. as far as I can tell, it's not used. Partly because it doesn't do very much
@baroquebobcat baroquebobcat rm require of removed file 2dff436
@baroquebobcat baroquebobcat clean up some lost changes removing the old test helper code 486d634
@baroquebobcat baroquebobcat use File::PATH_SEPARATOR for classpath when constructing classpaths i…
…n Rakefile

':' isn't the path separator on windows, so hardcoding the path separator leads to an inability to build on windows. :(

This fixes it.
@baroquebobcat baroquebobcat delete all the things! rm JRuby Compiler bits
the self hosted compiler covers everything at this point, so I'm deleting as much of the JRuby compiler components as I can get away with
@baroquebobcat baroquebobcat delay exiting to the main methods of commands so they're testable. Al…
…so more JRuby friendly
@baroquebobcat baroquebobcat deprecate -c for classpath in favor of -cp / --classpath
-c now works w/ new compiler, but spits out some stderr
@baroquebobcat baroquebobcat rm factory_test since it's subject is gone 30cf680
@baroquebobcat baroquebobcat rename handle_args back to applyArgs 93f4de2
@baroquebobcat baroquebobcat raise a better error in bytecode generation on missing local c2bb20b
@baroquebobcat baroquebobcat allow variable shadowing, fix rescue shadowing test failure 9cd7f6e
@baroquebobcat baroquebobcat fix up logging. typo, multi install, rm ruby impl
The Ruby log formatter isn't needed.
The Mirah one had a couple bugs
- it used split('.'), but java's split takes regex, so fixed that
- it would install itself multiple times, so I added a check to not create a new handler if one already existed
@baroquebobcat baroquebobcat log source of AST to be typed, where available df57318
@baroquebobcat baroquebobcat blocks_test whitespace 30955f6
@baroquebobcat baroquebobcat fix system reference in test helper 22efc0c
@baroquebobcat baroquebobcat fix BlocksTest#test_block_with_method_def
we were inferring block args too early and more importantly, introducing a scope around them. That put those args in a scope that was captured prematurely

Because they were captured, the compiler would think they were fields in a binding, even if the block was inlined as part of a macro, causing bytecode for an invalid field to be generated.
@baroquebobcat baroquebobcat rename Typer scope creation for methods to be more consistent b2aef50
@baroquebobcat baroquebobcat fix map collection extension method
backtick in pipes doesn't work when putting the block args in it. You need to put the contents of the args there.
In theory you could use backticks w/o pipes, but I haven't gotten that working

a little more discussion is at
@baroquebobcat baroquebobcat fix nested error descriptions popping up in test runs dc9f253
@baroquebobcat baroquebobcat add some more logging around redeclaring types b2cb3f0
@baroquebobcat baroquebobcat add position based content lookup to typer for debugging b283dd8
@baroquebobcat baroquebobcat add unary negation test fe16b3f
@baroquebobcat baroquebobcat whitespace in examples/macros/string_each_char.mirah 39d7946
@baroquebobcat baroquebobcat allow unquoted block args, both with and without pipes 89d4447
@baroquebobcat baroquebobcat Merge branch 'master' into bootstrap_with_new_compiler
@baroquebobcat baroquebobcat merged commit 5dbd5b9 into master Jun 16, 2014
ribrdb commented on 9cd7f6e Jul 2, 2014

Do you actually think supporting shadowing is a good idea, or are you just trying to fix the test?

The Mirah Community member

Just trying to fix the test. I've been trying to treat the new backend as a port of the existing one, with the same behavior. The JRuby implemented Mirah compiler currently shadows the variable in this case. The following code compiles and prints 1

a = 1
  raise "wut"
rescue => a
puts a # a is 1

In Java, shadowing isn't allowed.

class Test {
    public static void main(String[] args){
    Object e = 1;
        throw new RuntimeException("wut");
    } catch (Exception e){

gives you a compile error e is already defined in main(java.lang.String[])
    } catch (Exception e){
1 error

which I think is a reasonable thing to do.

Ruby doesn't treat rescues as introducing scope, so the variable defined at that point exists in the outer scope and is overridden.

 a=1;begin; raise 'wut';rescue => a;end
# a is #<RuntimeError: wut>

Interestingly for Ruby, this also means that

begin raise 'wut'; rescue => b;end

adds b to the outer scope.

I see a few options:

  • keep existing behavior: introducing a new scope that shadows vars outside it
  • adopt Java's behavior: introduce a new scope, but don't allow shadowing and error like it's a variable redeclaration.
  • add a little Ruby-ish: don't shadow, and if the types don't work out, error, but if the types do work out, treat it as assignment.

That was longer than I thought it was going to be.

Because Mirah has static types, I don't think emulating Ruby all the way is a good idea because we'd have to widen types to much and rely on dynamic dispatch. Following Java's approach would be pretty understandable.

I think the current behavior makes some sense in that it allows you to have multiple es in a method without complaining too much, so the compiler stays out of your way. On the other hand, it means that if you assume e outside the rescue will be overwritten by the rescue after the rescue finishes, you're going to have a bad time.

My problem with your first two options is that the rescue statement is the only place we create new scopes.
What if you create new variables inside the rescue block - do these exist outside?

If we want to support new scopes for rescue, I think we need to follow java and create new scopes for every block. But then we also need to change the ast to keep track of blocks. These all parse to if statements, with no indication of which should get a scope:

a = b if c
a && (b = c)
if a
 b = c
The Mirah Community member

After sleeping on it, I think following Ruby's behavior makes the most sense to me. There are a few cases where this gets a little tricky with primitives, but I think it'd be worth it for the ease of use / less time fighting w/ the compiler.

I started putting some thoughts together in this gist

speaking of gists. What do you think about me throwing my aspirational docs on what I'd like Mirah's behavior to be into the repo? I think doing that'd make my thoughts more visible / discussable.

Sure, checking in your ideas seems like a good idea.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.