42 Commits

Author SHA1 Message Date
narpfel
8afd059943 Fix linking Rust error messages to source (#8345)
The compiler output pane only links error messages to the source editor
when a filename is given. `parseRustOutput` didn’t parse the filename,
so Rust error messages were never linked.

This PR also simplifies the regex used to parse the `-->
filename:line:column` line in the `rustc` output. As far as I’m aware
(and I checked the history of the corresponding output in the `rustc`
source), the output format will always be `--> filename:line:column` and
not anything else accepted by the previous regex (no parentheses around
the line number, the column is not optional).
2025-12-20 13:54:45 +02:00
Matt Godbolt
f824efe73e Library updates and lint fixes (#8099)
* Minor updates only
* Added explicit radix parameter (10) to all Number.parseInt() calls throughout the codebase (new lint rule)
* Updated several @ts-ignore comments to @ts-expect-error for better TypeScript practices (new lint rule)
* Removed unnecessary @ts-ignore comments in some mode files (ditto)
* Used "none return" based arrow functions for some map stuff
* Replaced a `map()` call that didn't return anything to a for() loop
* Fixed up some cypress stuff, noting work for the future
2025-09-12 14:23:49 -05:00
Matt Godbolt
8734c3e492 Update biome (#7956)
- latest biome, and fix its configuration
- fixes "static" content to be globally configured too (instead of
per-line)
- fixes issues:
  - imports fixed up
  - `Date.now()` vs `+new Date()`
  - some unused things `_` prefixed
 
After discussion with the team, turned off the unused parameter warning.
2025-07-28 10:34:46 -05:00
Matt Godbolt
c4bb7f7c68 Fix unsafe type casting in assembly processing tools (#7767)
## Summary

Fixes unsafe type casting in assembly processing tools that was causing
`TypeError: text.split is not a function` runtime crashes.

## Root Cause Analysis

**COMPILER-EXPLORER-C2N** (57 occurrences) and **COMPILER-EXPLORER-AWW**
(184 occurrences):

The issue stemmed from tools making unsafe assumptions about
`compilationInfo.asm` type:

```typescript
// CompilationInfo.asm type (from types/compilation/compilation.interfaces.ts:168)
asm?: ParsedAsmResultLine[] | string;  // "Temp hack until we get all code to agree on type of asm"
```

**The bug sequence:**
1. `base-compiler.ts:3120` converts string assembly to parsed format:
`result.asm = [{text: result.asm}]`
2. Tools unsafely cast back to string: `compilationInfo.asm as string`
3. `AsmParser.processBinaryAsm()` calls `splitLines(asmResult)` 
4. If `asm` is actually `ParsedAsmResultLine[]`, `splitLines()` receives
an array
5. `text.split()` fails because arrays don't have `.split()` method

**Affected tools:** osaca-tool, x86to6502-tool, llvm-mca-tool

## Changes

### New Helper Functions in `utils.ts`:

1. **`extractTextLines(asm: string | any[]): string[]`**
   - Safely extracts text lines from union types
- Throws descriptive errors for unexpected types (will surface in
Sentry)

2. **`normalizeAsmToString(asm: string | any[] | undefined): string`**
- Centralizes the common pattern of converting union type to string for
parser consumption
   - Handles undefined gracefully

### Tool Fixes:

- **Removed unsafe casts**: `compilationInfo.asm as string` →
`normalizeAsmToString(compilationInfo.asm)`
- **Added null checks**: Explicit error handling for missing assembly
data
- **Type safety**: No more runtime type assumptions

## Impact

- Eliminates root cause of `text.split is not a function` errors (241+
occurrences combined)
- Maintains existing functionality - tools continue to work normally
- Better error messages when assembly data is missing
- Centralizes type handling logic for future maintainability

**Note:** The underlying architectural issue (union type "temp hack")
remains, but tools now handle it safely without crashes.

Fixes COMPILER-EXPLORER-C2N
Fixes COMPILER-EXPLORER-AWW

🤖 Generated with [Claude Code](https://claude.ai/code)

---------

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Mats Jun Larsen <mats@jun.codes>
2025-06-11 18:04:25 -05:00
Matt Godbolt
045e318645 Add some useful fs-extra-replacey utils and tests (#7448) 2025-02-25 15:07:57 -06:00
Matt Godbolt
698f9944cd Use node:fs/promises where possible (#7444)
- Updates a number of uses of `fs-extra` which were only for the
promisified fs calls.
- Makes a few sync calls async.
- Makes a few `read` calls that didn't specify a text mode, but then
parsed as a string...into the equivalent `readFile` call.
2025-02-25 13:26:31 -06:00
Matt Godbolt
de1a892264 Stdbuf fixes and updates for llvm IR (#7412)
- Don't mutate the `args` in-place which exposes the `-o0` of the stdbuf
args to the rest of the code (breaking a bunch of things)
- Check the return code of the LLVM parser dump and error if it's a
problem.

Found looking into #7410 but doesn't fix it
2025-02-19 10:24:54 -06:00
narpfel
2e69144b27 Add quickfixes for missing imports and feature flags (#7357) 2025-02-03 04:13:08 +00:00
Mats Jun Larsen
5eea63328f Migrate to Biome for linting and formatting (#7033) 2025-02-02 17:54:31 +00:00
narpfel
b3cc0c61e7 Parse Rust error message locations with multiple leading spaces (#7344)
Rust error message locations (` --> <source>:<line>:<col>`) can have
more than one leading space, e. g. when the source code snippet that is
shown has line numbers greater than ten.

In this example (https://godbolt.org/z/9W8xPv36c), the error message is
not be recognised as an error and there are no red squigglies in the
editor pane.
2025-01-30 15:57:50 -06:00
narpfel
f060417c34 Strip hyperlink escape sequences from editor pane diagnostics hover widget (#7342)
When passing `-fdiagnostics-urls=always`/`-Z terminal-urls=yes`, the
hyperlink escape sequence was not stripped from the mouse hover widget
in the editor pane.

Link: https://godbolt.org/z/3cP8jj8jc

Hover over the empty braces in the C++ editor or the `i32` in the Rust
editor:

Before:
```
warning: no return statement in function returning non-void []8;;https://gcc.gnu.org/onlinedocs/gcc-14.2.0/gcc/Warning-Options.html#index-Wno-return-type-Wreturn-type]8;;]x86-64 gcc 14.2 #1
error[]8;;https://doc.rust-lang.org/error_codes/E0308.htmlE0308]8;;]: mismatched typesrustc nightly #2
```

Now:
```
warning: no return statement in function returning non-void [-Wreturn-type]x86-64 gcc 14.2 #1
error[E0308]: mismatched typesrustc nightly #2
```
2025-01-30 14:14:22 -06:00
Matt Godbolt
02951a20db Unify types for tool args (#7199)
- Uses strings across the board in the UI part (no functional change
here from before; all state is the same as it was before).
- Sends _arrays_ in the POST, using the same `splitArguments` code as
the backend.
- Backend _still supports_ strings (though doesn't advertise), also
using same `splitArguments`.
- Moves `splitArguments` into common utils, and rephrases to avoid
unnecessary use of underscore and ES2021+ code.

Tested locally:
- with both old and new client code (ran new backend and old webcode to
show sending strings still works)
- with creating and removing tool windows (checked with `ldd` locally)
- with various strings on the client `moo foo "this is bad" #moo` and
even "error" things like `this is "badger` (with a missing close quote).
All works as you'd expect

Happy to break the "move the splitArguments" code into a separate PR if
that'd be easier to review separately.

Fixes #7195
2024-12-07 14:44:42 -06:00
Matt Godbolt
2dd0704dc6 Add a sleep util (#7172) 2024-12-02 18:22:14 +01:00
Mats Jun
3f2aaa6c4b Remove void type from eachLine (#7080) 2024-11-10 20:20:21 +01:00
Ofek
f6438f9c4d Store times in numbers only (#7023)
Also fixes #4655
2024-10-26 18:43:59 +03:00
Mats Jun
ce97bd1696 Replace old utils with JavaScript builtins (#7005) 2024-10-23 11:53:01 +02:00
Ofek
f5f00606f8 Tsifications galore (#6916)
Still mostly mindless numb work, one rename that touched many files
(`getArgumentParser` -> `getArgumentParserCls`), and a few real
improvements.
The goal is to be able to turn on `noImplicitAny` for the project, to
enforce higher code quality. 600 violations to go.
2024-10-01 12:26:46 +03:00
Ofek
f715dc2932 More tsification (#6877)
About half way through. Only 708 tsification errors to go..
2024-09-28 10:32:36 +03:00
Patrick Quist
d2c7a5222e Local/Remote Execution environment (#6413) 2024-05-26 22:09:01 +02:00
Patrick Quist
b8325cf0c6 eslint root setting and fixes (#6307) 2024-04-16 21:26:53 +02:00
Ofek
8dd09d1c1f Replace the deprecated substr with substring (#6236)
Just some minor homekeeping.
2024-03-10 10:04:29 +02:00
Patrick Quist
4605ebfb4b Add Fortran library support (#5533) 2024-02-09 23:31:05 +01:00
Patrick Quist
730437464d Fix semver ordering for libraries (#5959)
Fix #5951
Fix #5085

Extended the fictitious version number for non-numbers, so that trunk
can be listed higher than a `yyyymmdd` as a version (EVE uses this)
2024-01-08 22:10:25 -06:00
Ofek
464536e884 Fix #5945: tiny fix to stdout-parsing regexes (#5946)
Tiny change to regexes parsing compiler stdout lines, to make them stop
classifying lines like "(0.00 s) Setup: DONE" as errors.

One could imagine other, more thorough, fixes to [this
code](ec8f8e5d50/lib/utils.ts (L195-L202))
- it currently attempts to capture errors from all compilers, *not*
differentiating by compiler but instead by some general output formats
(`<source>`:line:col , or "file.ext":line, etc.). I settled for a 1-char
fix that seems to makes sense by itself.
2024-01-05 19:30:36 +02:00
Patrick Quist
455d92916a Execution with heaptrack (#5644) 2023-11-07 23:59:40 +01:00
Ofek
e7d266ac9c Fix #5255 (#5700) 2023-11-04 20:01:43 +01:00
Patrick Quist
7d192ccde1 add properties and test for cewrapper (#4761) 2023-03-18 11:46:27 +01:00
Mats Jun Larsen
633eb82d18 Transition to ECMAScript Modules (#4780)
Makes the Compiler Explorer app, and all the tooling ESM compatible.
Things that have been done:

1. The package.json has `type: module` now
2. All relative imports have a .js ending
3. All directory imports are now directory/index.js to comply with ESM
standards
4. Dependency node-graceful is now imported into tree, because the
package is broken under esm
5. Dependency p-queue has been bumped to 7.x with ESM support
6. Dependency profanities has been bumped to 3.x with ESM support
7. Webpack config is now both ESM and CommonJS compatible
8. Non-ESM compatible imports have been rewritten
9. ESLint configuration has been tweaked to not fail on .js imports
10. Mocha is now hacked together and ran with ts-node-esm
11. Webpack is now hacked together and ran with ts-node-esm
12. Webpack config is now ESM compatible, so that it can be used in the
dev server
13. Cypress code still runs commonjs, and has been excluded from the
tsconfig
14. All sinon mock tests have been commented out, because sinon module
mocks do not work with ESModules (because ESModules are immutable)

A lot of tests are now giving warnings/errors to stdout, yet still pass.
Docenizer codegenerator scripts have been updated, but I did not re-run
them, and instead just changed their code.

---------

Co-authored-by: Matt Godbolt <matt@godbolt.org>
2023-02-27 18:06:38 -06:00
Matt Godbolt
749319f791 Slightly more controversial bumpings (#4503)
- latest sentry, tar-stream, which, some yamljs versions
- latest eslint-* stuff
- latest webpack manifest
- Applies all the automatic fixes for newer lint rules
- Bump the webpack version

applies new tslint stuff
2022-12-28 11:42:14 -06:00
Rubén Rincón Blanco
c3eee72def Sort libs based on semver (#4153) 2022-10-12 21:12:44 +02:00
Rubén Rincón Blanco
d104aa628f Add some support for execution line linking in non tree mode (#4080) 2022-10-01 03:50:52 +02:00
Rubén Rincón Blanco
366cd5527c Adds llvm-cov tool (#4044) 2022-09-15 08:12:27 +02:00
Patrick Quist
b567856ab2 Clspvfixes (#4050) 2022-09-12 15:56:55 +02:00
Rubén Rincón Blanco
50aa2c9029 Move RE creation outside function scope (#4048)
No need to recreate the object for every compilation, even if the re gets compiled only once
2022-09-12 14:37:18 +02:00
Fred Tingaud
02ef879986 Move severity parsing with the rest of the output parsing. (#3821) 2022-07-01 00:30:57 +02:00
Patrick Quist
fe2687f864 allow hashes in arguments (#3726) 2022-05-27 22:51:03 +02:00
Patrick Quist
f83e184623 Minimal version of externalparser asm-parser (#3278) 2022-05-14 18:56:57 +02:00
Matt Godbolt
19ddc3384e Port cache code to Typescript (#3605)
* Port cache subsystem to typescript
* Extract an interface class
* Use async for s3 cache; add tests for failure case
2022-05-02 15:19:13 -05:00
Matt Godbolt
7bb57642a3 Lint fixes 2022-04-26 09:24:37 -05:00
Rubén Rincón Blanco
4965bd6c81 All semver comparisons now ensure it's safe to do so (#3562)
* All semver comparisons now ensure it's safe to do so

* Oops, use correct class

* Remove leftover import

* Leave the Zig fixes for another PR

* Fix linter

* Fix test issues

* Make linter happy, yet again

* What?

* Address PR review
2022-04-26 15:24:40 +02:00
Rubén Rincón Blanco
045c68d1bc Add strict tsc flag for the backend ts code (#3355) 2022-02-12 02:41:24 +01:00
Patrick Quist
6e79e098c4 Minimal backend typescript support (#3207)
* minimal ts support

Co-authored-by: Matt Godbolt <matt@godbolt.org>
2021-12-22 20:44:51 +01:00