Skip to content
This repository has been archived by the owner on Sep 24, 2020. It is now read-only.

Parser Regression in ObjectCreate initialization #38

Closed
watertree opened this issue Apr 12, 2012 · 2 comments
Closed

Parser Regression in ObjectCreate initialization #38

watertree opened this issue Apr 12, 2012 · 2 comments

Comments

@watertree
Copy link

When initializing a list as in the code below:

class Foo : Bar {
    public void Bar() {
        var a = new List<String> { "one", "two", "three" };
    }
}

The parser creates extra braces in the initialization (I was able to isolate it to the parser) so the resulting code would have extra braces (modified formatting since extra AST nodes are the problem):

class Foo : Bar  {
    public void Bar ()  {
        var a = new List<String> { { "one" }, { "two" }, { "three" } };
    }
}

I created a bisect script and boo program and was able to isolate the initial broken changeset to d6d1f08

To recreate, I ran git bisect as follows and placed the two scripts on the parent directory to NRefactory:

git bisect start HEAD 3eee3
git bisect run ../bisector.sh
ObjectCreateParserRegression.boo
import System.IO
import ICSharpCode.NRefactory.CSharp

code = """
class Foo : Bar {
    public void Bar() {
        var a = new List<String> { "one", "two", "three" };
    }
}
"""
parser = CSharpParser()
compilationUnit = parser.Parse(StringReader(code), "foo.cs", 0)
writer = StringWriter()
outVisitor = CSharpOutputVisitor(writer, CSharpFormattingOptions())
compilationUnit.AcceptVisitor(outVisitor)
print writer.ToString()
bisector.sh
WORKING_DIR=$PWD
echo $WORKING_DIR
BASE_DIR=NRefactory/ICSharpCode.NRefactory
cd ${BASE_DIR}.CSharp
echo "Cleaning"
xbuild /t:Clean > /dev/null 2>&1
echo "Building"
xbuild > /dev/null 2>&1
echo "Compile Script"
cd $WORKING_DIR
booc -lib:${BASE_DIR}/bin/Debug/ ObjectCreateParserRegression.boo > /dev/null 2>&1
mv ObjectCreateParserRegression.exe* $BASE_DIR/bin/Debug
echo "Run Script"
cd ${BASE_DIR}/bin/Debug
OPEN_BRACE_COUNT=$(mono ./ObjectCreateParserRegression.exe | grep '{' | wc -l)
cd $WORKING_DIR
# Correct result should have three open braces
if [ $OPEN_BRACE_COUNT -ne "3" ]; then
    echo "FAIL"$OPEN_BRACE_COUNT
    exit 1
fi
echo "SUCCESS"$OPEN_BRACE_COUNT
@mkrueger
Copy link

Should be fixed.

@awatertree
Copy link
Contributor

Thanks! Sorry for the junk added. I think my previous pull request only included the failing test, but I did add some junk to patch up a local version for this issue and it seems like you merged in some things I didn't intend to be merged. But thanks again, this project is amazing!

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

No branches or pull requests

3 participants