scala-ide / scala-ide-play2

Play 2 support for Scala IDE
107 stars 32 forks source link

Templates compiler bug #132

Open jroper opened 11 years ago

jroper commented 11 years ago

Well, I haven't actually seen this bug in Scala IDE, but I used

https://github.com/scala-ide/scala-ide-play2/pull/40

as a guide for upgrading to Scala 2.10 for SBT 0.13 in Play itself, and found that there was a bug in the way it handled byName parameters. That pull request changed calls to ValDef.mods.isByNameParam to ValDef.symbol.isByNameParam, but that doesn't actually correctly detect by name params. What it should do is use ValDef.mods.hasFlag(Flags.BYNAMEPARAM). Don't ask me exactly what's going on, it was mostly trial and error and looking at values in a debugger that allowed me to get it working.

dragos commented 11 years ago

It's not very clear to me how the template compiler uses the presentation compiler, but I agree that the symbol may not have the correct flags always. What is the manifestation of this bug for a user?

jroper commented 11 years ago

I think it uses it to parse the templates parameter declaration, so that it can generate a template of the right type. That is, if a template takes an Int and a String parameter, the type of the template must be Template2[Int, String].

The manifestation of the bug was, given a form with a by name parameter, eg:

@(foo: => String)

@foo

The template compiler would produce code that had references to that type that looked like this:

_root_.scala.<byname>[String]

which produced a compile error when scalac compiled it.

dragos commented 11 years ago

@jroper, thank you for the explanation.