Comments (5)
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.
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.
But the Q# code comment still changes the behavior between the commands
qsc.exe t3.qs
andqsc.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.
Can you file another issue?
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.
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)
- Kata playground: Remove profile selection option from tutorial exercises, HOT 1
- Build exception 'Could not load file or assembly' when building on Arm64 (Mac M3) HOT 1
- Kata playground: switching to tutorial and back to samples, disables "Run" button in the sample.
- Kata playground: Base profile selection for unsupported code shows the error for all kata exercises
- Add quantum phase estimation to the libraries HOT 1
- Add infrastructure for validating stand-alone Python files in samples
- Imports from Core that are not in the prelude do not generate auto-imports when selected from the completion list
- Callables from same file don't show up in the completions list
- Refactor completions generation to be more readable
- LaTeX rendering of nice numbers isn't always correct
- Generated documentation should include 'Std' way of referring items in the standard library
- IntelliSense error highlighting on one issue blocked by presence of another, in a different operation or later in the same operation
- Runtime error message and call stack printed as one line with \n HOT 1
- Histogram in VS Code is not cancelled by pressing Escape when prompted for the number of shots
- Update signed math library to match unstable API more closely
- Histograms in VS Code do not render until close to done running HOT 1
- Update `rustc_hash` and come to terms with the consequences
- [Playground] Keep track of playground state
- [Question] MathJax previewer for kata
- Detailed results for estimates widget all show "ERROR: Rendered has not been set"
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from qsharp.