Git Product home page Git Product logo

Comments (5)

bamarsha avatar bamarsha commented on August 25, 2024 1

I can reproduce with d6de278, but not latest main. I think #163 accidentally fixed this, because it changed the type checker to no longer try to resolve paths in types. Let me know if updating helps.

from qsharp.

kuzminrobin avatar kuzminrobin commented on August 25, 2024

Confirmed, the panic is resolved. I'm unblocked.


But the Q# code comment still changes the behavior between the commands qsc.exe t3.qs and qsc.exe - < t3.qs. I'm not sure if this is something that requires fixing or not, if yes then whether the current GitHub item needs to be reopened or a new one created. Up to you.
It is at least interesting to know why the comment affects the behavior, may be there is some hidden bug...

qsc.exe t3.qs

  × `i` not found in this scope
   ╭─[t3.qs:1:1]
 1 │ //
 2 │ namespace N{operation P(a:i):D{}}
   ·                           ┬
   ·                           ╰── not found
   ╰────


  × `D` not found in this scope
   ╭─[t3.qs:1:1]
 1 │ //
 2 │ namespace N{operation P(a:i):D{}}
   ·                              ┬
   ·                              ╰── not found
   ╰────


  × mismatched types
   ╭─[t3.qs:1:1]
 1 │ //
 2 │ namespace N{operation P(a:i):D{}}
   ·                               ─┬
   ·                                ╰── expected ?, found ()
   ╰────

qsc.exe - < t3.qs

  × entry point not found
  help: a single callable with the `@EntryPoint()` attribute must be present if no entry expression is provided

Also the following bug reporting seems misleading to me:

 2 │ namespace N{operation P(a:i):D{}}
   ·                               ─┬
   ·                                ╰── expected ?, found ()

Complains that found () whereas there is {} in the input stream.


Also the following fragment seems misleading to me in all the cases [t3.qs:1:1]. Refers to a wrong line and column.

from qsharp.

bamarsha avatar bamarsha commented on August 25, 2024

But the Q# code comment still changes the behavior between the commands qsc.exe t3.qs and qsc.exe - < t3.qs. I'm not sure if this is something that requires fixing or not, if yes then whether the current GitHub item needs to be reopened or a new one created. Up to you.
It is at least interesting to know why the comment affects the behavior, may be there is some hidden bug...

I think this is a separate bug with how qsc is reading stdin. It looks like the newline after the comment is getting eaten, because that error happens with an empty input file. Can you file another issue?

Also the following bug reporting seems misleading to me:

 2 │ namespace N{operation P(a:i):D{}}
   ·                               ─┬
   ·                                ╰── expected ?, found ()

Complains that found () whereas there is {} in the input stream.

The error is correct, although possibly confusing. The type of {} (empty block) is () (empty tuple).

Also the following fragment seems misleading to me in all the cases [t3.qs:1:1]. Refers to a wrong line and column.

This is how Miette renders errors. It shows the position of the start of the excerpt. Since the excerpt shows the entire file, it starts at line 1, column 1.

from qsharp.

kuzminrobin avatar kuzminrobin commented on August 25, 2024

Can you file another issue?

#188

The error is correct, although possibly confusing. The type of {} (empty block) is () (empty tuple).

FYI: This is really confusing that the function/operation body (or a block starting with { and ending with } and containing that body) has a data type (separate from the function/operation signature type). It makes an impression that one can declare/define a variable of that type. Is that really possible? If not then why do we need a data type for the function/operation body (or a block containing body)?

from qsharp.

bamarsha avatar bamarsha commented on August 25, 2024

I think the confusion comes from the fact that blocks are expressions. The type of the body block is equal to the return type of the function or operation. The return value of a function or operation is the value that comes from evaluating the body block as an expression. For example:

function AddOne(x : Int) : Int {
    let y = x + 1;
    y
}

When you call AddOne(2), x is bound to 2, and then the expression { let y = x + 1; y } is evaluated. So, yeah, the block has type Int. It just happens that an empty block evaluates to the unit tuple by default, so it has type () (also written as Unit).

from qsharp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.