Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Don't autothread Junction type object.
  • Loading branch information
jnthn committed Jun 6, 2015
1 parent 2ea7d3c commit 8363bbd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
15 changes: 11 additions & 4 deletions src/Perl6/Metamodel/BOOTSTRAP.nqp
Expand Up @@ -289,7 +289,9 @@ my class Binder {
}

# Report junction failure mode if it's a junction.
return $oval.WHAT =:= Junction ?? $BIND_RESULT_JUNCTION !! $BIND_RESULT_FAIL;
return $oval.WHAT =:= Junction && nqp::isconcrete($oval)
?? $BIND_RESULT_JUNCTION
!! $BIND_RESULT_FAIL;
}

# Also enforce definedness constraints.
Expand All @@ -302,7 +304,9 @@ my class Binder {
!! "Parameter '$varname'";
$error[0] := "$what requires a '$class' type object, but an object instance was passed";
}
return $oval.WHAT =:= Junction ?? $BIND_RESULT_JUNCTION !! $BIND_RESULT_FAIL;
return $oval.WHAT =:= Junction && nqp::isconcrete($oval)
?? $BIND_RESULT_JUNCTION
!! $BIND_RESULT_FAIL;
}
if $flags +& $SIG_ELEM_DEFINED_ONLY && !nqp::isconcrete($oval) {
if nqp::defined($error) {
Expand All @@ -312,7 +316,9 @@ my class Binder {
!! "Parameter '$varname'";
$error[0] := "$what requires a '$class' instance, but a type object was passed. Did you forget a .new?";
}
return $oval.WHAT =:= Junction ?? $BIND_RESULT_JUNCTION !! $BIND_RESULT_FAIL;
return $oval.WHAT =:= Junction && nqp::isconcrete($oval)
?? $BIND_RESULT_JUNCTION
!! $BIND_RESULT_FAIL;
}
}
}
Expand Down Expand Up @@ -2223,7 +2229,8 @@ BEGIN {
$i := 0;
while $i < $num_args {
if !nqp::captureposprimspec($capture, $i) {
if nqp::istype(nqp::captureposarg($capture, $i), Junction) {
my $arg := nqp::captureposarg($capture, $i);
if nqp::istype($arg, Junction) && nqp::isconcrete($arg) {
$has_junc_args := 1;
}
}
Expand Down
10 changes: 1 addition & 9 deletions src/vm/jvm/runtime/org/perl6/rakudo/Binder.java
Expand Up @@ -125,14 +125,6 @@ else if (count == -1)
fail, arity, arity + 1 == count ? "or" : "to" , count, numPosArgs);
}

/* Returns an appropriate failure mode (junction fail or normal fail). */
private static int junc_or_fail(RakOps.GlobalExt gcx, SixModelObject value) {
if (value.st.WHAT == gcx.Junction)
return BIND_RESULT_JUNCTION;
else
return BIND_RESULT_FAIL;
}

/* Binds any type captures. */
public static void bindTypeCaptures(ThreadContext tc, SixModelObject typeCaps, CallFrame cf, SixModelObject type) {
long elems = typeCaps.elems(tc);
Expand Down Expand Up @@ -175,7 +167,7 @@ private static int assignAttributive(ThreadContext tc, CallFrame cf, String varN

/* Returns an appropriate failure mode (junction fail or normal fail). */
private static int juncOrFail(ThreadContext tc, RakOps.GlobalExt gcx, SixModelObject value) {
if (value.st.WHAT == gcx.Junction)
if (value.st.WHAT == gcx.Junction && Ops.isconcrete(value, tc))
return BIND_RESULT_JUNCTION;
else
return BIND_RESULT_FAIL;
Expand Down

2 comments on commit 8363bbd

@usev6
Copy link
Contributor

@usev6 usev6 commented on 8363bbd Jun 7, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to break the build on JVM with the following error

src/vm/jvm/runtime/org/perl6/rakudo/Binder.java:170: error: bad operand types for binary operator '&&'
        if (value.st.WHAT == gcx.Junction && Ops.isconcrete(value, tc))
                                          ^
  first type:  boolean
  second type: long
1 error
*** Error code 1

Stop.
make: stopped in /usr/home/christian/perl6/perl6-roast-data/rakudo.jvm

After changing that line to

if (value.st.WHAT == gcx.Junction && Ops.isconcrete(value, tc) != 0)

the build on JVM was successful again.

But the error message for the following command does look LTA, so that's probably not enough to fix this:

$ perl6-j -e 'sub foo($) {}; foo(Junction)'
Nominal type check failed for parameter 'null'
  in sub foo at -e:1
  in block <unit> at -e:1

@lizmat
Copy link
Contributor

@lizmat lizmat commented on 8363bbd Jun 7, 2015 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.