# Slate brackets parsing bug

**URL:** <https://forums.unrealengine.com/t/slate-brackets-parsing-bug/312701>\
**Category:** UI\
**Tags:** unreal-engine, bug-report, slate, CPP, question\
**Created:** [March 26, 2015, 3:43pm UTC](https://forums.unrealengine.com/t/slate-brackets-parsing-bug/312701 "2015-03-26T15:43:11Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Elringus](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/elringus/32/1017568_2.png) [@Elringus](https://forums.unrealengine.com/u/Elringus)\
**Post date:** [March 26, 2015, 3:43pm UTC](https://forums.unrealengine.com/t/slate-brackets-parsing-bug/312701/1 "2015-03-26T15:43:11Z")

</div>

I have the following statement:

```
SNew(SListView<TSharedPtr<FArtifact>>)
	.ListItemsSource(&ArtifactList)
	.OnGenerateRow_Lambda([](TSharedPtr<FArtifact> artifact, const TSharedRef<STableViewBase>& ownerTable)->TSharedRef<ITableRow>
	{ 
		return SNew(STableRow<TSharedPtr<FArtifact>>, ownerTable)
				[
					SNew(SButton)
					.Text(artifact->Rules.ID)
					.OnClicked_Lambda([artifact]()->FReply{ ULogic::AnalyzeArtifact(*artifact.Get()); return FReply::Handled(); })
				]; 
	})

```

On compiling I have an error (full log in the attachement), about the left bracket ‘[’ after the “return SNew(STableRow\>, ownerTable)” statement was not matched correctly. But, as you can see, it is matched correctly.

If I remove the lambda statement of the Button OnClicked event, everything begins to compile correctly. So, I assume, that the parser is having problem with the lamdas capture list brackets, mistaken them with the slate content brackets.

---

<div class="post-metadata">

**Author:** ![Jamie\_Dale](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/jamie_dale/32/1165413_2.png) [@Jamie\_Dale](https://forums.unrealengine.com/u/Jamie_Dale)\
**Post date:** [March 26, 2015, 3:46pm UTC](https://forums.unrealengine.com/t/slate-brackets-parsing-bug/312701/2 "2015-03-26T15:46:52Z")

</div>

Yes, this is a [known issue](https://connect.microsoft.com/VisualStudio/feedback/details/899632/c-cannot-define-lambdas-inside-operator-when-defining-a-member-function-inside-a-class) with the parser in Visual Studio 2013 (it _might_ be fixed for VS2015). Clang does not have this issue.

A workaround would be to declare your lambda outside of the Slate declarative syntax.

---

<div class="post-metadata">

**Author:** ![Elringus](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/elringus/32/1017568_2.png) [@Elringus](https://forums.unrealengine.com/u/Elringus)\
**Post date:** [March 26, 2015, 6:13pm UTC](https://forums.unrealengine.com/t/slate-brackets-parsing-bug/312701/3 "2015-03-26T18:13:48Z")

</div>

Thank you for the answer! I’ve tried defining the lambda outside of the slate like this:

```
auto onArtifactButtonClicked = [](TSharedPtr<FArtifact> artifact)->FReply{ ULogic::AnalyzeArtifact(*artifact.Get()); return FReply::Handled(); };

```

Then used it in the slate:

```
SNew(SListView<TSharedPtr<FArtifact>>)
	.ListItemsSource(&artifactList)
	.OnGenerateRow_Lambda([onArtifactButtonClicked](TSharedPtr<FArtifact> artifact, const TSharedRef<STableViewBase>& ownerTable)->TSharedRef<ITableRow>
	{ 
		return SNew(STableRow<TSharedPtr<FArtifact>>, ownerTable)
				[
					SNew(SButton)
					.Text(artifact->Rules.ID)
					.OnClicked_Lambda(onArtifactButtonClicked(artifact))
				]; 
	})

```

But now I have the following compilation error:

```
c:\program files\epic games\4.7\engine\source\runtime\core\public\delegates\Tuple.h(113): error C2064: term does not evaluate to a function taking 0 arguments

```

Maybe I’m doing something wrong?

---

<div class="post-metadata">

**Author:** ![Jamie\_Dale](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/jamie_dale/32/1165413_2.png) [@Jamie\_Dale](https://forums.unrealengine.com/u/Jamie_Dale)\
**Post date:** [March 26, 2015, 6:22pm UTC](https://forums.unrealengine.com/t/slate-brackets-parsing-bug/312701/4 "2015-03-26T18:22:03Z")

</div>

You’ve called the lambda with the parameter `artifact`, so you’re actually passing the return value of that lambda, `FReply`, into `OnClicked_Lambda`.

If you want to bind `artifact` as a parameter, you’ll have to use the full delegate creation syntax (you can normally avoid this, however we don’t have the Slate syntax sugar setup for lambdas as you typically just capture your data in them rather than use delegate bindings).

```
SNew(SButton)
.Text(artifact->Rules.ID)
.OnClicked(FOnClicked::CreateLambda(onArtifactButtonClicked, artifact))

```

---

<div class="post-metadata">

**Author:** ![Elringus](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/elringus/32/1017568_2.png) [@Elringus](https://forums.unrealengine.com/u/Elringus)\
**Post date:** [March 26, 2015, 7:42pm UTC](https://forums.unrealengine.com/t/slate-brackets-parsing-bug/312701/5 "2015-03-26T19:42:06Z")

</div>

Thank you very much for your help! I really appreciate the active support here 🙂

The suggested CreateLambda func hadn’t really worked (got me ‘error C2661: … no overloaded function takes 2 arguments’ at compilation), but the CreateStatic worked just fine.
