|
|
Re: Default Scope Shadowing [message #1716483 is a reply to message #1716439] |
Fri, 04 December 2015 10:24 |
|
On 03/12/2015 21:26, Larry LeBron wrote:
> I'm working through Lorenzo Bettini's book, and have gotten to the
> section on scoping. I'm reading the ebook, and at location 4124, he
> briefly discusses shadowing and proposes this test to verify that the
> default ScopeProvider will properly provide shadowing.
>
>
> @Test def void testVariableShadowsParamLinking() {
> '''
> class A {
> A m(A a) {
> A a = null;
> return a;
> }
> }
> '''.parse.classes.head.methods.head => [
> assertNoErrors
> // the local variable should shadow the param
> body.statements.head.assertSame(
> (returnStatement.expression as SJSymbolRef).symbol)
> ]
> }
>
>
> However, this test fails for me with the default provider. Am I missing
> something, or is this just an incorrect statement from the book, or
> something that worked "out of the box" in prior versions of Xtext? The
> test passes with the custom ScopeProvider implementation presented later
> in the chapter.
Hi
how does this test fail with the default scope provider? I mean, does
assertNoErrors fail or the other assert?
cheers
Lorenzo
--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
HOME: http://www.lorenzobettini.it
Xtext Book:
http://www.packtpub.com/implementing-domain-specific-languages-with-xtext-and-xtend/book
HOME: http://www.lorenzobettini.it
TDD Book: https://leanpub.com/tdd-buildautomation-ci
Xtext Book: https://www.packtpub.com/application-development/implementing-domain-specific-languages-xtext-and-xtend-second-edition
|
|
|
|
Re: Default Scope Shadowing [message #1729455 is a reply to message #1716439] |
Thu, 14 April 2016 09:40 |
|
On 03/12/2015 21:26, Larry LeBron wrote:
> I'm working through Lorenzo Bettini's book, and have gotten to the
> section on scoping. I'm reading the ebook, and at location 4124, he
> briefly discusses shadowing and proposes this test to verify that the
> default ScopeProvider will properly provide shadowing.
>
>
> @Test def void testVariableShadowsParamLinking() {
> '''
> class A {
> A m(A a) {
> A a = null;
> return a;
> }
> }
> '''.parse.classes.head.methods.head => [
> assertNoErrors
> // the local variable should shadow the param
> body.statements.head.assertSame(
> (returnStatement.expression as SJSymbolRef).symbol)
> ]
> }
>
>
> However, this test fails for me with the default provider. Am I missing
> something, or is this just an incorrect statement from the book, or
> something that worked "out of the box" in prior versions of Xtext? The
> test passes with the custom ScopeProvider implementation presented later
> in the chapter.
>
> Thanks!
Hi
while working on this chapter for the 2nd edition I confirm that with
the default implementation of scope provider the test fails; probably
something has changed in Xtext after the book was written, sorry about
that. Of course, I fixed that in the new edition :)
cheers
Lorenzo
--
Prof. Lorenzo Bettini, Computer Science, DISIA, Univ. Firenze
HOME: http://www.lorenzobettini.it
Xtext Book:
http://www.packtpub.com/implementing-domain-specific-languages-with-xtext-and-xtend/book
HOME: http://www.lorenzobettini.it
TDD Book: https://leanpub.com/tdd-buildautomation-ci
Xtext Book: https://www.packtpub.com/application-development/implementing-domain-specific-languages-xtext-and-xtend-second-edition
|
|
|
Powered by
FUDForum. Page generated in 0.03466 seconds