dub icon indicating copy to clipboard operation
dub copied to clipboard

Throw instead of assertion and better message

Open MrcSnm opened this issue 1 year ago • 3 comments

The assertion crashed code-d and gave no information on what was wrong.

MrcSnm avatar Oct 22 '24 19:10 MrcSnm

⚠️ This PR introduces new deprecations:

source/dub/dependency.d(91,72): Error: found `")\n\tthis(string n, Dependency s = Dependency.init) @safe pure\n\t{\n\t\tthis.name = PackageName(n);\n\t\tthis.spec = s;\n\t}\n\n\t// Remove once deprecated overload is gone\n\tthis(PackageName n, Dependency s = Dependency.init) @safe pure nothrow @nogc\n\t{\n\t\tthis.name = n;\n\t\tthis.spec = s;\n\t}\n\n\tint opCmp(in typeof(this) other) @safe const {\n\t\treturn name == other.name\n\t\t\t? spec.opCmp(other.spec)\n\t\t\t: name.opCmp(other.name);\n\t}\n\n\t/// Name of the referenced package.\n\tPackageName name;\n\n\t/// Dependency specification used to select a particular version of the package.\n\tDependency spec;\n}\n\n/**\n\tRepresents a dependency specification.\n\n\tA dependency specification either represents a specific version or version\n\trange, or a path to a package. In addition to that it has `optional` and\n\t`default_` flags to control how non-mandatory dependencies are handled. The\n\tpackage name is notably not part of the dependency specification.\n*/\nstruct Dependency {\n\t/// We currently support 3 'types'\n\tprivate alias Value = SumType!(VersionRange, NativePath, Repository);\n\n\t/// Used by `toString`\n\tprivate static immutable string[] BooleanOptions = [ "` when expecting `;` or `=`, did you mean `first argument = optional`?
source/dub/dependency.d(91,80):        expression: `")\n\tthis(string n, Dependency s = Dependency.init) @safe pure\n\t{\n\t\tthis.name = PackageName(n);\n\t\tthis.spec = s;\n\t}\n\n\t// Remove once deprecated overload is gone\n\tthis(PackageName n, Dependency s = Dependency.init) @safe pure nothrow @nogc\n\t{\n\t\tthis.name = n;\n\t\tthis.spec = s;\n\t}\n\n\tint opCmp(in typeof(this) other) @safe const {\n\t\treturn name == other.name\n\t\t\t? spec.opCmp(other.spec)\n\t\t\t: name.opCmp(other.name);\n\t}\n\n\t/// Name of the referenced package.\n\tPackageName name;\n\n\t/// Dependency specification used to select a particular version of the package.\n\tDependency spec;\n}\n\n/**\n\tRepresents a dependency specification.\n\n\tA dependency specification either represents a specific version or version\n\trange, or a path to a package. In addition to that it has `optional` and\n\t`default_` flags to control how non-mandatory dependencies are handled. The\n\tpackage name is notably not part of the dependency specification.\n*/\nstruct Dependency {\n\t/// We currently support 3 'types'\n\tprivate alias Value = SumType!(VersionRange, NativePath, Repository);\n\n\t/// Used by `toString`\n\tprivate static immutable string[] BooleanOptions = [ "`

BUILD FAILED ❌ Basic dub build failed! Please check your changes again.

Build statistics:

 statistics (-before, +after)
 executable size=5297464 bin/dub
-rough build time=66s
+rough build time=0s
Full build output
DUB version 1.38.0, built on Jul  4 2024
LDC - the LLVM D compiler (1.39.0):
  based on DMD v2.109.1 and LLVM 18.1.6
  built with LDC - the LLVM D compiler (1.39.0)
  Default target: x86_64-unknown-linux-gnu
  Host CPU: znver3
  http://dlang.org - http://wiki.dlang.org/LDC


  Registered Targets:
    aarch64     - AArch64 (little endian)
    aarch64_32  - AArch64 (little endian ILP32)
    aarch64_be  - AArch64 (big endian)
    amdgcn      - AMD GCN GPUs
    arm         - ARM
    arm64       - ARM64 (little endian)
    arm64_32    - ARM64 (little endian ILP32)
    armeb       - ARM (big endian)
    avr         - Atmel AVR Microcontroller
    bpf         - BPF (host endian)
    bpfeb       - BPF (big endian)
    bpfel       - BPF (little endian)
    hexagon     - Hexagon
    lanai       - Lanai
    loongarch32 - 32-bit LoongArch
    loongarch64 - 64-bit LoongArch
    mips        - MIPS (32-bit big endian)
    mips64      - MIPS (64-bit big endian)
    mips64el    - MIPS (64-bit little endian)
    mipsel      - MIPS (32-bit little endian)
    msp430      - MSP430 [experimental]
    nvptx       - NVIDIA PTX 32-bit
    nvptx64     - NVIDIA PTX 64-bit
    ppc32       - PowerPC 32
    ppc32le     - PowerPC 32 LE
    ppc64       - PowerPC 64
    ppc64le     - PowerPC 64 LE
    r600        - AMD GPUs HD2XXX-HD6XXX
    riscv32     - 32-bit RISC-V
    riscv64     - 64-bit RISC-V
    sparc       - Sparc
    sparcel     - Sparc LE
    sparcv9     - Sparc V9
    spirv       - SPIR-V Logical
    spirv32     - SPIR-V 32-bit
    spirv64     - SPIR-V 64-bit
    systemz     - SystemZ
    thumb       - Thumb
    thumbeb     - Thumb (big endian)
    ve          - VE
    wasm32      - WebAssembly 32-bit
    wasm64      - WebAssembly 64-bit
    x86         - 32-bit X86: Pentium-Pro and above
    x86-64      - 64-bit X86: EM64T and AMD64
    xcore       - XCore
   Upgrading project in /home/runner/work/dub/dub/
    Starting Performing "release" build using /opt/hostedtoolcache/dc/ldc2-1.39.0/x64/ldc2-1.39.0-linux-x86_64/bin/ldc2 for x86_64.
    Building dub 1.39.0-beta.1+commit.20.g0b58417e: building configuration [application]
source/dub/dependency.d(91,14): Error: found `Use` when expecting `)`
source/dub/dependency.d(91,18): Error: found `the` when expecting `;` following `throw` statement
source/dub/dependency.d(91,34): Error: found `accepts` when expecting `;` or `=`, did you mean `constructor that = a`?
source/dub/dependency.d(91,47): Error: found `"PackageName"` when expecting `;` or `=`, did you mean `accepts a = as`?
source/dub/dependency.d(91,63): Error: found `as` when expecting `;` following expression
source/dub/dependency.d(91,49):        expression: `"PackageName"`
source/dub/dependency.d(91,72): Error: found `")\n\tthis(string n, Dependency s = Dependency.init) @safe pure\n\t{\n\t\tthis.name = PackageName(n);\n\t\tthis.spec = s;\n\t}\n\n\t// Remove once deprecated overload is gone\n\tthis(PackageName n, Dependency s = Dependency.init) @safe pure nothrow @nogc\n\t{\n\t\tthis.name = n;\n\t\tthis.spec = s;\n\t}\n\n\tint opCmp(in typeof(this) other) @safe const {\n\t\treturn name == other.name\n\t\t\t? spec.opCmp(other.spec)\n\t\t\t: name.opCmp(other.name);\n\t}\n\n\t/// Name of the referenced package.\n\tPackageName name;\n\n\t/// Dependency specification used to select a particular version of the package.\n\tDependency spec;\n}\n\n/**\n\tRepresents a dependency specification.\n\n\tA dependency specification either represents a specific version or version\n\trange, or a path to a package. In addition to that it has `optional` and\n\t`default_` flags to control how non-mandatory dependencies are handled. The\n\tpackage name is notably not part of the dependency specification.\n*/\nstruct Dependency {\n\t/// We currently support 3 'types'\n\tprivate alias Value = SumType!(VersionRange, NativePath, Repository);\n\n\t/// Used by `toString`\n\tprivate static immutable string[] BooleanOptions = [ "` when expecting `;` or `=`, did you mean `first argument = optional`?
source/dub/dependency.d(131,56): Error: found `optional` when expecting `;` following expression
source/dub/dependency.d(91,80):        expression: `")\n\tthis(string n, Dependency s = Dependency.init) @safe pure\n\t{\n\t\tthis.name = PackageName(n);\n\t\tthis.spec = s;\n\t}\n\n\t// Remove once deprecated overload is gone\n\tthis(PackageName n, Dependency s = Dependency.init) @safe pure nothrow @nogc\n\t{\n\t\tthis.name = n;\n\t\tthis.spec = s;\n\t}\n\n\tint opCmp(in typeof(this) other) @safe const {\n\t\treturn name == other.name\n\t\t\t? spec.opCmp(other.spec)\n\t\t\t: name.opCmp(other.name);\n\t}\n\n\t/// Name of the referenced package.\n\tPackageName name;\n\n\t/// Dependency specification used to select a particular version of the package.\n\tDependency spec;\n}\n\n/**\n\tRepresents a dependency specification.\n\n\tA dependency specification either represents a specific version or version\n\trange, or a path to a package. In addition to that it has `optional` and\n\t`default_` flags to control how non-mandatory dependencies are handled. The\n\tpackage name is notably not part of the dependency specification.\n*/\nstruct Dependency {\n\t/// We currently support 3 'types'\n\tprivate alias Value = SumType!(VersionRange, NativePath, Repository);\n\n\t/// Used by `toString`\n\tprivate static immutable string[] BooleanOptions = [ "`
source/dub/dependency.d(131,69): Error: found `efault` when expecting `;` following expression
source/dub/dependency.d(131,64):        expression: `", "d`
source/dub/dependency.d(146,14): Error: found `Use` when expecting `;` following expression
source/dub/dependency.d(131,75):        expression: `" ];\n\n\t// Shortcut to create >=0.0.0\n\tprivate enum ANY_IDENT = " * ";\n\n\tprivate Value m_value = Value(VersionRange.Invalid);\n\tprivate bool m_optional;\n\tprivate bool m_default;\n\n\t/// A Dependency, which matches every valid version.\n\tpublic static immutable Dependency Any = Dependency(VersionRange.Any);\n\n\t/// An invalid dependency (with no possible version matches).\n\tpublic static immutable Dependency Invalid = Dependency(VersionRange.Invalid);\n\n\tdeprecated("`
source/dub/dependency.d(146,35): Error: found `instead` when expecting `;` following expression
source/dub/dependency.d(146,18):        expression: `"Dependency.Any"`
source/dub/dependency.d(148,14): Error: found `Use` when expecting `;` following expression
source/dub/dependency.d(146,42):        expression: `")\n\tstatic @property Dependency any() @safe { return Dependency(VersionRange.Any); }\n\tdeprecated("`
source/dub/dependency.d(148,39): Error: found `instead` when expecting `;` following expression
source/dub/dependency.d(148,18):        expression: `"Dependency.Invalid"`
source/dub/dependency.d(194,14): Error: found `Instantiate` when expecting `;` following expression
source/dub/dependency.d(148,46):        expression: `")\n\tstatic @property Dependency invalid() @safe\n\t{\n\t\treturn Dependency(VersionRange.Invalid);\n\t}\n\n\t/** Constructs a new dependency specification that matches a specific\n\t\tpath.\n\t*/\n\tthis(NativePath path) @safe\n\t{\n\t\tthis.m_value = path;\n\t}\n\n\t/** Constructs a new dependency specification that matches a specific\n\t\tGit reference.\n\t*/\n\tthis(Repository repository) @safe\n\t{\n\t\tthis.m_value = repository;\n\t}\n\n\t/** Constructs a new dependency specification from a string\n\n\t\tSee the `versionSpec` property for a description of the accepted\n\t\tcontents of that string.\n\t*/\n\tthis(string spec) @safe\n\t{\n\t\tthis(VersionRange.fromString(spec));\n\t}\n\n\t/** Constructs a new dependency specification that matches a specific\n\t\tversion.\n\t*/\n\tthis(const Version ver) @safe\n\t{\n\t\tthis(VersionRange(ver, ver));\n\t}\n\n\t/// Construct a version from a range of possible values\n\tthis (VersionRange rng) @safe\n\t{\n\t\tthis.m_value = rng;\n\t}\n\n\tdeprecated("`
source/dub/dependency.d(194,30): Error: found `"Repository"` when expecting `;` following expression
source/dub/dependency.d(194,26):        expression: `the`
source/dub/dependency.d(194,50): Error: { } expected following `struct` declaration
source/dub/dependency.d(194,55): Error: found `the` when expecting `(`
source/dub/dependency.d(194,66): Error: missing closing `)` after `with (string`
source/dub/dependency.d(194,74): Error: found `")\n\tthis(Repository repository, string spec) @safe\n\t{\n\t\tassert(repository.m_ref is null);\n\t\trepository.m_ref = spec;\n\t\tthis(repository);\n\t}\n\n\t/// If set, overrides any version based dependency selection.\n\tdeprecated("` when expecting `;` following expression
source/dub/dependency.d(194,66):        expression: `directly`
source/dub/dependency.d(203,24): Error: found `new` when expecting `;` or `=`, did you mean `Construct a = "Dependency"`?
source/dub/dependency.d(203,30): Error: basic type expected, not `"Dependency"`
Error /opt/hostedtoolcache/dc/ldc2-1.39.0/x64/ldc2-1.39.0-linux-x86_64/bin/ldc2 failed with exit code 1.
BUILD FAILED
STAT:statistics (-before, +after)
STAT:executable size=5297464 bin/dub
STAT:rough build time=0s

github-actions[bot] avatar Oct 22 '24 19:10 github-actions[bot]

I didn't get any stack trace somehow (I had to run on debugger), but this is a minimal reproducible example:

duberr.zip

MrcSnm avatar Oct 22 '24 19:10 MrcSnm

It's not handling the following propery:

			"dependencies": {
				":version-a": "*"
			}

I think that's a limitation of the parser, will see if I can fix it properly.

Geod24 avatar Oct 22 '24 21:10 Geod24

Closing in favor of the fix: #3028

Geod24 avatar May 14 '25 23:05 Geod24