Skip to content

Interop with xp-forge/partial broken #15

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

Closed
thekid opened this issue Oct 31, 2017 · 2 comments
Closed

Interop with xp-forge/partial broken #15

thekid opened this issue Oct 31, 2017 · 2 comments
Labels

Comments

@thekid
Copy link
Member

thekid commented Oct 31, 2017

Dynamic traits cannot be resolved, resulting in Cannot instantiate incomplete type com\example\user\lang\partial\Value

@thekid thekid added the bug label Oct 31, 2017
@thekid
Copy link
Member Author

thekid commented Oct 31, 2017

Fix:

--- src/main/php/lang/ast/Parse.class.php       2017-10-31 17:30:56.570161100 +0100
+++ src/main/php/lang/ast/Parse.class.php.new   2017-10-31 17:30:46.244551200 +0100
@@ -402,19 +402,23 @@
       $this->token= $this->advance();

       if ('{' === $this->token->symbol->id) {
+        $types= [];
         while ('}' !== $this->token->symbol->id) {
           $this->token= $this->advance();
           $class= $this->token->value;
+          $types[]= $import.$class;
           $this->scope->import($import.$class);
           $this->token= $this->advance();
         }
         $this->token= $this->advance();
       } else {
+        $types= [$import];
         $this->scope->import($import);
       }

       $this->token= $this->expect(';');
       $node->arity= 'import';
+      $node->value= $types;
       return $node;
     });

--- src/main/php/lang/ast/Emitter.class.php     2017-10-31 17:31:04.758931100 +0100
+++ src/main/php/lang/ast/Emitter.class.php.new 2017-10-31 17:31:01.913885000 +0100
@@ -189,11 +189,11 @@
   }

   protected function emitPackage($node) {
-    $this->out->write('namespace '.$node->value.";\n");
+    $this->out->write('namespace '.$node->value.';');
   }

   protected function emitImport($node) {
-    // NOOP
+    $this->out->write('use '.implode(',', $node->value).';');
   }

   protected function emitAnnotation($node) {

@thekid
Copy link
Member Author

thekid commented Oct 31, 2017

Maybe this should be part of the compiler itself?

use lang\partial\Value;

class User is Value {
  // ..
}

This would call e.g. $node= \lang\ast\Is::transform($node, 'Value').

More complex matter => RFC needed

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

No branches or pull requests

1 participant