Fix failure to parse a syntax case involving unexpected usage of annotated expressions (fixes#11691).
The root cause of the bug was usage of the `matches!` macro in a situation where a `match` statement should have been used to enforce exhaustiveness.
- I have corrected the bug, and reviewed all usages of the `matches!` macro. I didn't find any other *incorrect* usages of `matches!`, but I found and replaced some potentially *fragile* uses. I also simplified some unnecessary uses of `matches!`, replacing them with expressions that are more-obviously correct.
- Stricter parsing: It is now a syntax error for an inline annotation to occur in the RHS of an application (e.g. `fn @Tail_Call recur`)--the precedence in this case may be surprising, so parentheses should be used around the annotated expression.
`parse_all_enso_files.sh`: This PR does not affect any AST in the .enso corpus.
Prefer `distribution/lib/Standard/*` files over the files in `built-distribution/enso-engine-*/enso-0.0.0-dev/lib/Standard/`. This solves the common error when _one debugs thru files_ and edits them just to find out _they are rewritten by next build_.
# Important Notes
The support for locating `alternativeFile` is only enabled for developers. E.g. when Enso version is `0.0.0-dev`. This is satisfied when one uses:
```bash
enso$ sbt
sbt:enso> runEngineDistribution --run test/Base_Tests --debug
```
* Drop soft-shutdown on last client disconnect
Suspend on Windows confuses the reconnection logic and triggers a full
shutdown. This change simply drop shutdown on last client disconnect and
expects and explicit command.
* Various cherry-picks
Minor cherry-picks from the debugging branch. Should reduce the amount
of non-critical warnings.
The previous code was throwing `UnknownIdentifierException` when a module wasn't found. That's pretty misleading. Especially when Truffle infrastructure converts such exception to another one. Enso has a dedicated error when module cannot be found. Let's use that one.
* Delegate slf4j in HostClassLoader to system class loader
That way in Enso and Java code any usage of slf4j will use the same
configuration as the rest of the process that started it.
Tricky to test, will post an example in GH PR.
* Semi-working test
* Make sure memory appender starts clean
Appender is re-used among many tests, collecting all logs. This is
problematic when we want to test the contents of logs.
Fixes occasional issues on CI https://github.com/enso-org/enso/actions/runs/12028665644/job/33537703634?pr=11663#step:7:3840
```
- should interrupt running execution context *** FAILED *** (2 seconds, 295 milliseconds)
0 did not equal 1 (RuntimeAsyncCommandsTest.scala:254)
```
The issue is caused by the asynchronous nature of the test. By the point when the interrupt command is sent the program is already terminated but the test assumes that the program is still running.
`ydoc-server` compilation requires generation of `ydoc.cjs` resource that can take time and slow down the libraries development (building the enso distribution). This PR splits Ydoc into a library and the server part to avoid JS resources generation during the compilation of the language server.
Changelog:
- refactor: Ydoc into ~~`ydoc`~~ `ydoc-polyglot` library and `ydoc-server` server parts
- update: language server to depend on the ~~`ydoc`~~ `ydoc-polyglot` library
close#11481
Changelog:
- update: handle `MultiTypeValue` results in the execution instrument
- update: language server protocol supports multi-type values
- update: GUI uses only the first type of a multi-type value when
# Important Notes
GUI uses only the first type of the intersection. See the difference between `Integer&Text` and `Text&Integer`:
https://github.com/user-attachments/assets/29efc89b-c223-4043-8dff-9cdae1987f0c
* EnsoObject is an abstract class, not an interface.
- Also, EnsoObject exports hasLanguage and getLanguage interop messages.
- BranchRecord converted to class
* Implement public getters in BranchResult
* Fix compilation of EnsoFile
* Add test that all enso values must have language
* Revert EnsoException - remove
* DataflowError and PanicException implement hasLanguage and getLanguage
* DataflowError is not EnsoObject - change signatures in some builtins
* Add more members to Module.isMemberInvocable.
Keep in sync with doInvoke.
* Revert "DataflowError and PanicException implement hasLanguage and getLanguage"
This reverts commit b30f3961b7.
* Update the test - test only non-primitive and non-exception values
* Fix indexes in CodeLocationsTest
* Add more members to Function.isMemberInvocable
Keep in sync with doInvoke.
* EnsoObject.toDisplayString delegates to toString method
* EnsoObject.toDisplayString is behind TruffleBoundary
* Warning exports InteropLibrary which delegates to value.
With the exception of toDisplayString message.
* WithWarnings needs to explicitly export toDisplayString.
It is not automatically delegated because it is implemented in the super type.
* EnsoObject.toDisplayString just throws AssertionError
* AssertionError is behind TruffleBoundary
* Implement toDisplayString on some truffle objects
* Warning exports WarningsLibrary
* Revert "Warning exports WarningsLibrary"
This reverts commit a06c672db5.
* Add some warnings test
* Warning.isNull is always false
Even if it wraps Nothing
* Add some unnecessary methods to fix the compilation
* EnsoObject.toDisplayString is abstract
* ImportExportScope.toDisplayString is behind TruffleBoundary.
This fixes native-image build of engine-runner.
* Hide some toDisplayString methods behind TruffleBoundary
This fixes native-image build of engine-runner.
Bypassing failing test.
While working on #11482 and enhancing the tests suite with more tests based on `type Complex` a [getRootNode() did not terminate in 100000 iterations](https://github.com/enso-org/enso/pull/11525#issuecomment-2476171597) problem was discovered. Detailed investigation revealed that the existing `ReadArgumentCheckNode` infrastructure was able to create a **cycle** of parent pointers in the Truffle AST.
The problem was in intricate manipulation of the AST while rewriting internals in `ReadArgumentCheckNode`. This PR avoids such manipulation by _refactoring the type checking code_. `ReadArgumentNode` knows nothing about types anymore. When a type check is needed, `IrToTruffle` adds additional `TypeCheckValueNode.wrap` around the `ReadArgumentNode` - that breaks the **vicious circle**.
All the _type checks_ nodes are moved to its own package. All but one of the classes are made package private. The external API for doing _type checking_ is concentrated into `TypeCheckValueNode`.
Fixes `--jvm` option, given to the native image. This was failing on my machine, because when given `--jvm` option, the runner was trying to find the `java` executable from the distribution manager's runtime (on my system located in `~/.local/share/enso/runtime`) and it used the first runtime found. But the first runtime on my system is JDK 17.
The `--jvm` option now tries to:
- Find a JDK from the distribution manager that has the same version as the JDK used for building the engine.
- If there is not an exact version match, it tries to find a runtime from distribution manager that is *newer*.
- If none, fallback to system-wide search
- System-wide search tries to find `java` from `$JAVA_HOME` and from `$PATH`. But this is just a fallback.
# Important Notes
- Added test to Engine CI jobs that pass `--jvm` argument to a native image of engine-runner
- ea3af5ffbc
- `runtime-version-manager` sbt project migrated to a JPMS module
- `engine-runner` now depends on `runtime-version-manager`.
- Removed unnecessary stuff in `runtime-version-manager` dealing with outdated `gu` Graal Updater utility.
- Extracted [GraalVersionManager](1455b025cb/lib/scala/runtime-version-manager/src/main/java/org/enso/runtimeversionmanager/components/GraalVersionManager.java) from [RuntimeVersionManager](d2e8994700/lib/scala/runtime-version-manager/src/main/scala/org/enso/runtimeversionmanager/components/RuntimeVersionManager.scala)
* Fix Logger's name in stdlib
Somehow SLF4J is able to recognize correctly the provided Logger's name
and print it to the user. Java's Logger is
not.
In addition, we setup SLF4J's configuration, meaning that log-levels are
correctly respected.
For a simple project:
```
from Standard.Base import all
from Standard.Base.Logging import all
type Foo
main =
IO.println "Hello World!"
Foo.log_message level=..Warning "I should warn you about something..."
Foo.log_message level=..Info "Should be seen? By default we only show up-to warnings level"
Foo.log_message level=..Severe "Something went really bad!"
```
This change demonstrates the fix.
Before:
```
> enso --run simple-logging.enso
Hello World!
Nov 08, 2024 6:08:07 PM com.oracle.truffle.host.HostMethodDesc$SingleMethod$MHBase invokeHandle
WARNING: I should warn you about something...
Nov 08, 2024 6:08:07 PM com.oracle.truffle.host.HostMethodDesc$SingleMethod$MHBase invokeHandle
INFO: Should be seen? By default we only show up-to warnings level
Nov 08, 2024 6:08:07 PM com.oracle.truffle.host.HostMethodDesc$SingleMethod$MHBase invokeHandle
SEVERE: Something went really bad!
Foo
```
After:
```
> enso --run simple-logging.enso
Hello World!
[WARN] [2024-11-08T18:03:37+01:00] [simple-logging.Foo] I should warn you about something...
[ERROR] [2024-11-08T18:03:37+01:00] [simple-logging.Foo] Something went really bad!
Foo
```
* Update distribution/lib/Standard/Base/0.0.0-dev/src/Logging.enso
Co-authored-by: Radosław Waśko <radoslaw.wasko@enso.org>
* Test stdlib logs by using MemoryAppender
Added `getEvents` member to `MemoryAppender` so that it is possible to
retrieve individual log messages from tests and test their presence.
Required opening up to some modules to retrieve internals of loggers.
* nit
* small tweaks to eliminate module warnings
---------
Co-authored-by: Radosław Waśko <radoslaw.wasko@enso.org>
`MetadataStorage` is mutable. Using `Object.equals` in `IR.copy` methods to check whether a _copy is needed_ isn't enough. The fact that two storages are `Object.equal` may be just temporary. Replacing the checks in 69 `IR.copy` methods with identity check - e.g. `ne` in Scala which is `==` in Java.
Using proper structural check inside of `MetadataStorage` fixes#11171.
# Important Notes
I [used this regex](https://github.com/enso-org/enso/issues/11171#issuecomment-2463908932) to find out 69 instances of `IR.copy`:
![69 copy methods](https://github.com/user-attachments/assets/257580b9-54fc-4199-88ad-a22103b0041f)
and I modified all 69 of them.
* Fix logging in CLI
Previously, unless `--logger-connect` was used, CLI would always
fallback to console logging. In addition it would be misconfigured if
`application.conf` was provided with logging configuration.
This change makes sure that CLI uses the same logging infrastructure as
the rest of the system.
As a result, CLI will now by default not only log to the console and
respect the provided configuration but also log to the file system.
* Update docs
* c&p error
* More examples
The ultimate goal is to reduce the method calls necessary for `Vector.map`.
# Important Notes
- I managed to reduce the number of Java stack frames needed for each `Vector.map` call from **150** to **22** (See https://github.com/enso-org/enso/pull/11363#issuecomment-2432996902)
- Introduced `Stack_Size_Spec` regression test that will ensure that Java stack frames needed for `Vector.map` method call does not exceed **40**.
* Don't cancel aborted jobs immediately
Rather than cancelling Futures that capture jobs' logic,
this change introduces a two-level system:
- interrupt all jobs softly via ThreadInterrupted at safepoints
- if safepoint is not executed within some time period or it is
but the job is still not cancelled, trigger a hard-interrupt
by cancelling the job explicitly, if possible
Closes#11084.
* Only cancel Future when you mean it
Soft-cancelling a future only to later call it with `mayInterrupt` set
to `true` has no effect in the latter case.
Changed the logic so that interrupting a Future will really enforce it.
Ocassionally some commands should not attempt to run soft cancellations
- we know they will re-execute the program.
* Replace Thread.sleep with Future.get
No while loops etc, it's much easier to reason about what is soft and
hard interrupt supposed to do.
* Better comments/logs
* nit
* PR review
* Make test more robust
Move documentation into documentable types (implements #11302).
# Important Notes
GUI:
- Distinguish expression and statement
- `Ast.Ast` is still present, as the base class for AST objects. Most references to `Ast.Ast` are now references to `Ast.Expression`. Operations on blocks use `Ast.Statement`.
- `Ast.parse` has been replaced with: `Ast.parseExpression`, `Ast.parseStatement`, and `Ast.parseBlock`
- `syncToCode` is internally context-aware; it parses the provided code appropriately depending on whether its AST is an expression, a statement, or the top level of a module.
- Remove `wrappingExpression` / `innerExpression` APIs: Wrapper types have been eliminated; modifier lines are now fields inside parent types.
- Simplify AST printing:
- Fully implemented autospacing in `concreteChildren` implementations; the type returned by `concreteChildren` now ensures that spacing has been fully resolved.
- Eliminate `printBlock` / `printDocs`: `concreteChildren` is now aware of indentation context, and responsible for indentation of its child lines.
- The `Pattern` type is now parameterized to identify the AST type it constructs. The `Pattern.parseExpression` function helps create a `Pattern<Expression>`.
- Refactor `performCollape` for testability.
- e2e tests: Improve table viz test: It still doesn't pass on my Mac, but these changes are necessary if not sufficient.
Compiler (TreeToIr):
- An expression in statement context is now found in an `ExpressionStatement` wrapper.
- Documentation for a `Function` is now found inside the function node.
- Deduplicate some polyglot-function logic.
`Meta.get_qualified_type_name` correctly returns fully qualified type name when running a single file from a project with `enso --run Proj/src/Main.enso`.
- ✅ Alter default `Any.pretty` so constructor is prefixed with type name (as needed now).
![image](https://github.com/user-attachments/assets/72d5ff2f-b567-47e2-becf-2e4acd4d089d)
- ✅ Tests for `pretty` on `Date`.
- `pretty` for ✅ `Date_Time` and ✅ `Time_Of_Day` improved to not have as much noise.
- `pretty` for ✅ `Period`, ✅ `Date_Range` and ✅ `Range`.
- Added custom `pretty` for ✅ `Vector` and ✅ `Array` as built-in method doesn't call through to overrides.
- Added custom `pretty` for ✅ `Column` and ✅ `Table`.
- Bug fix for `pretty` in `Time_Zone` so calls through to `pretty` of the zone_id to ensure safely escaped.
- Initial `default_widget` for `Date` and `Time_Of_Day`.
- Improve widget for `Date.to_date_time`.
![image](https://github.com/user-attachments/assets/18bc1d88-8ea9-42d0-8a9c-bc873e5d6835)
- `to_text`, `to_display_text` and `pretty` for `Enso_Secret`
![image](https://github.com/user-attachments/assets/d850c109-d1af-4b6f-a450-013c4d137805)
- private constructor for `Enso_Secret` as can't be correctly built directly.
- Use `_` for the testing methods in `HTTP` to clarify they shouldn't be used in general code.
close#11237
Changelog:
- update: implement special case for a line removal when calculating the changeset
# Important Notes
Note that the graph is still re-calculated when the node is re-added (by pressing `ctrl-z`). The reason is that the engine processes edits on the textual level and there is not enough information to do similar workarounds. The issue becomes irrelevant when we switch to the direct tree manipulation in Ydoc.
https://github.com/user-attachments/assets/c85afde8-6386-44df-82b5-6fb0cca5205b
Related to #9165 work. Let's make sure the current behavior of `if`/`then`/`else` is properly tested by a unit test. Extracting test created as part of #11365 to verify it really describes the current behavior.
Improves the speed of `ExecutionEnvironment.hasContextEnabled`.
# Important Notes
Local speedup of `Map_Error_Benchmark_Vector_ignore.Map_Id_All_Errors` benchmark is roughly ???.
Move annotations into fields of Function and ConstructorDefinition.
# Important Notes
New syntax: Constructor argument-definition lines
- Each argument in a type-constructor definition may be specified on its own (indented) line.
Relaxed syntax: Unparenthesized arguments to annotations
- A generic annotation now uses the rest of the line as its argument expression; the expression no longer needs to be parenthesized.