Nesting of requests causing nsc symtab exception? (cyclic aliasing or subtyping involving type HttpPackage)

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Nesting of requests causing nsc symtab exception? (cyclic aliasing or subtyping involving type HttpPackage)

LouisJB
Hi,

I appear to be hitting some compiler issue when I attempt to nest a chain of requests, along the lines of:


http(((xmlReq / "res/0") <<< body) <> { rsp =>
  ...
  http((xmlReq / "res" / id.toString) <> { rsp2 =>
    ...
   
    http(((xmlReq / "res" / id.toString) << body.toString) <> { rsp3 =>
      ...
    })
  })
})

Whereas if I run the requests without the nesting it works - but this means I need some vars rather than vals to set the response and then process it (not so nice)

Just wondering if this is a known issue/limitation - probably with the compiler (using 2.8beta1) but I thought I'd ask here first in case there are any recommended patterns for chaining requests together that avoid vars, deep nesting and this potential compiler issue?

Compiler exception appears to be:

Exception in thread "main" scala.tools.nsc.symtab.Types$TypeError: cyclic aliasing or subtyping involving type HttpPackage
        at scala.tools.nsc.typechecker.Contexts$Context.error(Contexts.scala:318)
        at scala.tools.nsc.typechecker.Infer$Inferencer.error(Infer.scala:273)
        at scala.tools.nsc.typechecker.Typers$Typer.checkNotLocked$1(Typers.scala:332)
        at scala.tools.nsc.typechecker.Typers$Typer.checkNonCyclic(Typers.scala:336)
        at scala.tools.nsc.typechecker.Typers$Typer.checkNonCyclic(Typers.scala:364)
        at scala.tools.nsc.typechecker.Typers$Typer.checkNonCyclic(Typers.scala:338)
        at scala.tools.nsc.typechecker.Typers$Typer.checkNonCyclic(Typers.scala:364)
        at scala.tools.nsc.typechecker.Typers$Typer.checkNonCyclic(Typers.scala:374)
        at scala.tools.nsc.typechecker.Typers$Typer.typedDefDef(Typers.scala:1814)
        at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:3751)
        at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:4087)
        at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:4140)
        at scala.tools.nsc.typechecker.Typers$Typer.typedStat$1(Typers.scala:2098)
        at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$20.apply(Typers.scala:2166)
        at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$20.apply(Typers.scala:2166)
        at scala.collection.immutable.List.loop$1(List.scala:116)
        at scala.collection.immutable.List.mapConserve(List.scala:133)
        at scala.tools.nsc.typechecker.Typers$Typer.typedStats(Typers.scala:2166)
        at scala.tools.nsc.typechecker.Typers$Typer.typedTemplate(Typers.scala:1513)
        at scala.tools.nsc.typechecker.Typers$Typer.typedClassDef(Typers.scala:1296)
        at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:3742)
        at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:4087)
        at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:4140)
        at scala.tools.nsc.typechecker.Typers$Typer.typedStat$1(Typers.scala:2098)
        at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$20.apply(Typers.scala:2166)
        at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$20.apply(Typers.scala:2166)
        at scala.collection.immutable.List.loop$1(List.scala:116)
...

Any thoughts?

thanks, Louis
Reply | Threaded
Open this post in threaded view
|

Re: Nesting of requests causing nsc symtab exception? (cyclic aliasing or subtyping involving type HttpPackage)

n8han
Administrator
Have you tried this in 2.7.7? I know I've nested at least 3 levels deep using futures, but the types may not have been dependent in the same way. If it turns out to be a compiler bug I'll need to isolate it with a smaller test case, which I think can *probably* do.

Nathan
Reply | Threaded
Open this post in threaded view
|

Re: Nesting of requests causing nsc symtab exception? (cyclic aliasing or subtyping involving type HttpPackage)

drew
I just got this under scala 2.9.0-1 with only two levels of nesting:

build.scala.versions=2.9.0-1

  val dispatch = "net.databinder" %% "dispatch-http" % "0.7.8"


    def sync() = {
      Http x (indexer.s / "records/filter"
              <<? Map("index" -> uri,
                      "modifiedSince" -> m)
              as_str) {
        case (200, res, ent, body) => {
          val subjs = ...
          for (res <- subjs.subjects) {
            val subj = res.uri
            Http x (indexer.s / "records" <<? Map("index" -> uri,
                                                  "uri" -> subj) as_str) {
              case (200, res, ent, body) => {
                val record = parse(body()).asInstanceOf[RecordsResponse]
                addDocument(record.record)
              }
            }
          }
        }
      }
    }


scala.tools.nsc.symtab.Types$TypeError: cyclic aliasing or subtyping involving type HttpPackage
        at scala.tools.nsc.typechecker.Contexts$Context.error(Contexts.scala:291)
        at scala.tools.nsc.typechecker.Infer$Inferencer.error(Infer.scala:205)
...
Reply | Threaded
Open this post in threaded view
|

Re: Nesting of requests causing nsc symtab exception? (cyclic aliasing or subtyping involving type HttpPackage)

n8han
Administrator
Explicit type annotations will usually solve it. For example, this fails:

  Http(:/("technically.us") >- { str => Http(:/("technically.us") as_str )})

but this works

  Http(:/("technically.us") >- { str => Http(:/("technically.us") as_str ): String})

This is the price we pay for having an interface that can return either a value or a value wrapped in some `HttpPackage` (e.g. a future).

Nathan

On 09/02/2011 01:25 PM, drew [via Databinder] wrote:
I just got this under scala 2.9.0-1 with only two levels of nesting:

build.scala.versions=2.9.0-1

  val dispatch = "net.databinder" %% "dispatch-http" % "0.7.8"


    def sync() = {
      Http x (indexer.s / "records/filter"
              <<? Map("index" -> uri,
                      "modifiedSince" -> m)
              as_str) {
        case (200, res, ent, body) => {
          val subjs = ...
          for (res <- subjs.subjects) {
            val subj = res.uri
            Http x (indexer.s / "records" <<? Map("index" -> uri,
                                                  "uri" -> subj) as_str) {
              case (200, res, ent, body) => {
                val record = parse(body()).asInstanceOf[RecordsResponse]
                addDocument(record.record)
              }
            }
          }
        }
      }
    }


scala.tools.nsc.symtab.Types$TypeError: cyclic aliasing or subtyping involving type HttpPackage
        at scala.tools.nsc.typechecker.Contexts$Context.error(Contexts.scala:291)
        at scala.tools.nsc.typechecker.Infer$Inferencer.error(Infer.scala:205)
...



To start a new topic under Databinder, email [hidden email]
To unsubscribe from Databinder, click here.