Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9135411
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:49:15+00:00 2026-06-17T08:49:15+00:00

How can I check multiple expressions in one Matcher fragment? For example: class Foo

  • 0

How can I check multiple expressions in one Matcher fragment?

For example:

class Foo extends Specification {
   "Retrieving open issues" should {
      "return expected properties with expected data" in     {
         val issue = Bar.openIssues.head

         issue must not beNull
         issue.number must beEqualTo(1) 
         issue.state must beEqualTo("open")
         issue.title must beEqualTo("first issue")
      }
   }
}

Gives error

[error]  type mismatch;
[error]  found   : Int
[error]  required: org.specs2.matcher.Matcher[Issue]
[error]                         issue.number must beEqualTo(1)

Eric references a “classical” type inference issue in this comment, but couldn’t find an answer.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T08:49:15+00:00Added an answer on June 17, 2026 at 8:49 am

    The problem lies in this line:

    issue must not beNull
    

    Because it is written in operator notation the compiler must infer dots and parentheses at the right position. Following the rule that obj meth arg is the same as obj.meth(arg) this line is interpreted as:

    issue.must(not).beNull<missing_arg>
    

    beNull is a member called on the returned value of issue.must(not). The compiler follows the rules of operator notation and treats it as meth while issue.must(not) is treated as obj. Because operator notation always requires that a call must have the form obj meth arg, in the above example the compiler is hold to throw an error because of invalid syntax. But it doesn’t do it since there are two further rules:

    1. The white space that separates the identifiers in operator notation must not only contain spaces or tabs, it can also contain a single(!) new line sign.
    2. If no arg can be found an empty argument list is inserted implicitly.

    Because of (1), the compiler treats the next line as arg:

    issue.must(not).beNull(
    issue.number).must(beEqualTo(1))
    

    This is not how the code should be interpreted. To solve the problem it is possible to enclose the whole expression in parentheses:

    (issue must not beNull)
    

    or to separate the lines by an empty line:

    issue must not beNull
    
    issue.number must beEqualTo(1)
    

    Both solutions work because of (2) the compiler can insert an empty argument list.

    Note: If (2) must be applied this is also called a postfix operator. In 2.10 they treat a warning because – as one can see with this question – they can lead to tricky behavior.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have to write a litte daemon that can check multiple (could be up
i have a countries list. Each user can check multiple countries. Once saved, this
I need to create check box list content for Example departments and user can
In my requirement, a user can select multiple check-boxes. However after checking each check-box
I noticed that I can open multiple tabs from different buttons/links. :) What i
How can I check for multiple instances of my visual basic application? When the
With this code, I can check multiple rows in a table. But what I
I have a very simple question: how can I check multiple MySQL columns against
I want to check multiple controls state in one method, in C# this would
Can check out here alt text http://51hired.com/static/problem.bmp

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.