Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve error message for which(fn, types) #47369

Merged
merged 1 commit into from
Feb 3, 2024

Conversation

apaz-cli
Copy link
Member

Error messages for MethodError are much more helpful in determining why the method was not successfully dispatched than simply "No unique matching method found."

Fixes #47322

@vtjnash vtjnash added the triage This should be discussed on a triage call label Oct 28, 2022
@vtjnash
Copy link
Member

vtjnash commented Oct 28, 2022

Marking for triage, for discussion of whether MethodError is appropriate here. Since it is not true in the strict since of the runtime error, but it is an error that seems to be essentially what #47322 requested, and it does get the fancy printing that was desired there. Unless what was desired was just a very minimal mention of whether it had an ambiguity (which might just involve some plumbing to have the ambig boolean computed by ml_matches be included in the error message here)

@JeffBezanson
Copy link
Member

Suggestion from triage: stringify the MethodError to wrap it in an ErrorException that adds some text like "call would result in the following method error:".

@JeffBezanson JeffBezanson removed the triage This should be discussed on a triage call label Nov 10, 2022
@apaz-cli apaz-cli force-pushed the ap/which branch 2 times, most recently from 6141895 to 9551f58 Compare November 12, 2022 00:03
base/reflection.jl Outdated Show resolved Hide resolved
@StefanKarpinski
Copy link
Member

Wouldn't it make more sense to wrap the actual method error and then display it correctly?

@apaz-cli
Copy link
Member Author

Test for #47559 yoinked from #47566, thanks @Seelengrab ❤️ 🙂

@brenhinkeller brenhinkeller added the error messages Better, more actionable error messages label Nov 17, 2022
@apaz-cli
Copy link
Member Author

apaz-cli commented Nov 17, 2022

After CI runs, there should still be one failing test, which is part of SparseArrays. I've submitted a PR above, and mentioned this PR in it.

We should also run pkgeval to try to find anything else that this breaks.

Also, is this sort of change to MethodError something that we should triage? If we don't want to change how MethodError prints, a062067 is a complete implementation that passes tests.

@maleadt
Copy link
Member

maleadt commented Nov 17, 2022

@nanosoldier runtests(ALL, vs = ":master")

@JuliaLang JuliaLang deleted a comment from apaz-cli Nov 17, 2022
@nanosoldier
Copy link
Collaborator

Your package evaluation job has completed - possible new issues were detected. A full report can be found here.

@maleadt
Copy link
Member

maleadt commented Nov 18, 2022

Quite some errors because master is 1.10 and this branch 1.9 (JuliaCI/Nanosoldier.jl#131).

@KristofferC
Copy link
Member

Looking at the logs this is running on a quite old Julia commit. Running on merge commit with PkgEval would be nice :P

@vtjnash
Copy link
Member

vtjnash commented Nov 18, 2022

Those are a Pkg bug and not just a branch difference though, right? Eg https://s3.amazonaws.com/julialang-reports/nanosoldier/pkgeval/by_hash/e9ab711_vs_5f0da83/Casacore.primary.log

@maleadt
Copy link
Member

maleadt commented Nov 18, 2022

Rebased. This is also a good PR to test some new PkgEval features, so sorry for the noise (I'll delete those comments afterwards):

@nanosoldier runtests(["AnyMOD", "Casacore", "ClimaTimeSteppers", "CxxWrap", "DickeModel", "FMIFlux", "HomalgProject", "MParT", "Oscar", "Polymake", "QML", "QSimulator", "RangeEnclosures", "SDPA", "Singular", "StaticTools", "TuringGLM", "Z3", "openPMD", "ADI", "AIBECS", "AffineInvariantMCMC", "AlgebraicMultigrid", "ArrayLayouts", "AstroIC", "AstroIO", "AtomGraphs", "AvailablePotentialEnergyFramework", "BIGUQ", "BM3DDenoise", "Baytes", "BetaML", "Bio3DView", "BlobTracking", "BlockDecomposition", "BlockTriangularForm", "Boltz", "BrokenRecord", "CDLmotif", "CSDP", "CairoMakie", "CartesianJoin", "Catlab", "Causal", "CausalInference", "CellSegmentation", "ChainPlots", "ChaoticEncryption", "CineFiles", "CitableImage", "ClimateERA", "ClimateModels", "CollisionDetection", "ColorTypes", "CorrelationFunctions", "CorrelationTrackers", "CumulantsFeatures", "CumulantsUpdates", "DINCAE", "DLMReader", "DSP", "DataAssimilationBenchmarks", "DeconvOptim", "DifferentiableCollisions", "DifferentiableTrajectoryOptimization", "Discord", "Dojo", "DojoEnvironments", "DrelTools", "DrillMudsThermalProps", "EFTfitter", "EasyABM", "EditorsRepo", "EulerCharacteristic", "EvoDynamics", "ExplainableAI", "ExtremeLearning", "FHIRClientXML", "FMI", "FaceDetection", "FastMakie", "FastRunningMedian", "FastVision", "FatDatasets", "FeedbackNets", "FileIO", "FlowAtlas", "FlowWorkspace", "FourierFlows", "FourierGPE", "FunctionTabulations", "GAP", "GCMAES", "GEMPIC", "GMT", "Gaugefields", "GaussianMixtureRegressions", "GaussianMixtures", "GeneralizedSylvesterSolver", "GeophysicalFlows", "GraphDataFrameBridge", "Graphene", "GreenFunc", "GridapGmsh", "HypertextLiteral", "ImageUtils", "ImagineFormat", "InMemoryDatasets", "IndependentComponentAnalysis", "IndividualDisplacements", "InteractiveDynamics", "InventoryManagement", "IsotopeTableDF", "IterativeLQR", "IterativeRefinement", "JLD2", "JavisNB", "JobSchedulers", "Juice", "JunctionTrees", "Jutul", "JutulDarcy", "Knet", "KnetLayers", "KnetNLPModels", "KomaMRI", "KroneckerTools", "LIBSVM", "LabelledGraphs", "LatticeDiracOperators", "LatticeQCD", "LazyAlgebra", "Leaflet", "Lehmann", "LightOSM", "LinearInterpolators", "MCMCDebugging", "MPIMapReduce", "MPIReco", "MPITestImages", "MRICoilSensitivities", "MRIFiles", "MRIReco", "MRISimulation", "MRIsim", "MagmaThermoKinematics", "ManifestUtilities", "MaterialReconstruction", "MatrixMerge", "MendelImpute", "MetaGraphs", "MetaGraphsNext", "Mitosis", "MolecularGraphKernels", "MonolithicFEMVLFS", "MultiScaleTreeGraph", "MultilayerGraphs", "MultiscaleGraphSignalTransforms", "MutualInformationImageRegistration", "NbodyGradient", "NeidArchive", "NeutronTransport", "NewsLookout", "NighttimeLights", "Nonconvex", "Nullables", "ODEHybrid", "OSMMakie", "OSQP", "OVERT", "Observers", "OceanStateEstimation", "Oceanostics", "PDENLPModels", "POMDPStressTesting", "PSSFSS", "ParameterEstimocean", "Parsers", "PassiveTracerFlows", "Peridynamics", "PharmaceuticalClassification", "Photodynamics", "PlanktonIndividuals", "PlantBiophysics", "PlantGeom", "PlutoStaticHTML", "PointEstimateMethod", "PoreMatMod", "PorousMaterials", "PowerAnalytics", "PowerModelsAnalytics", "PowerSystemsMaps", "ProbabilisticCircuits", "Probably", "PubChemCrawler", "QXContexts", "QXTools", "QXZoo", "RandomMatrices", "RandomMatrixDistributions", "RankRevealing", "RayTracing", "RecoverPose", "RegularizationTools", "Reproduce", "ReusableFunctions", "RiskAdjustedLinearizations", "RoMEPlotting", "RobustPmap", "SMLMData", "SMLMFrameConnection", "SMLMSim", "SUNRepresentations", "Seleroute", "SimpleSolvers", "SmoothingSplines", "SnowyOwl", "SocialSamplingTheory", "SolverBenchmark", "SpecTools", "SpeedyWeather", "SpinGlassNetworks", "SpinGlassPEPS", "StableTrees", "StatisticalGraphics", "TcpInstruments", "TeneT", "TensorBoardLogger", "TensorGames", "TensorKitManifolds", "UnifiedPseudopotentialFormat", "UserConfig", "VisualGeometryDatasets", "WGPUgfx", "WhereTraits", "YaoQX"])

@nanosoldier
Copy link
Collaborator

Your job failed. cc @maleadt

@maleadt
Copy link
Member

maleadt commented Nov 18, 2022

@nanosoldier runtests(["AnyMOD", "Casacore", "ClimaTimeSteppers", "CxxWrap", "DickeModel", "FMIFlux", "HomalgProject", "MParT", "Oscar", "Polymake", "QML", "QSimulator", "RangeEnclosures", "SDPA", "Singular", "StaticTools", "TuringGLM", "Z3", "openPMD", "ADI", "AIBECS", "AffineInvariantMCMC", "AlgebraicMultigrid", "ArrayLayouts", "AstroIC", "AstroIO", "AtomGraphs", "AvailablePotentialEnergyFramework", "BIGUQ", "BM3DDenoise", "Baytes", "BetaML", "Bio3DView", "BlobTracking", "BlockDecomposition", "BlockTriangularForm", "Boltz", "BrokenRecord", "CDLmotif", "CSDP", "CairoMakie", "CartesianJoin", "Catlab", "Causal", "CausalInference", "CellSegmentation", "ChainPlots", "ChaoticEncryption", "CineFiles", "CitableImage", "ClimateERA", "ClimateModels", "CollisionDetection", "ColorTypes", "CorrelationFunctions", "CorrelationTrackers", "CumulantsFeatures", "CumulantsUpdates", "DINCAE", "DLMReader", "DSP", "DataAssimilationBenchmarks", "DeconvOptim", "DifferentiableCollisions", "DifferentiableTrajectoryOptimization", "Discord", "Dojo", "DojoEnvironments", "DrelTools", "DrillMudsThermalProps", "EFTfitter", "EasyABM", "EditorsRepo", "EulerCharacteristic", "EvoDynamics", "ExplainableAI", "ExtremeLearning", "FHIRClientXML", "FMI", "FaceDetection", "FastMakie", "FastRunningMedian", "FastVision", "FatDatasets", "FeedbackNets", "FileIO", "FlowAtlas", "FlowWorkspace", "FourierFlows", "FourierGPE", "FunctionTabulations", "GAP", "GCMAES", "GEMPIC", "GMT", "Gaugefields", "GaussianMixtureRegressions", "GaussianMixtures", "GeneralizedSylvesterSolver", "GeophysicalFlows", "GraphDataFrameBridge", "Graphene", "GreenFunc", "GridapGmsh", "HypertextLiteral", "ImageUtils", "ImagineFormat", "InMemoryDatasets", "IndependentComponentAnalysis", "IndividualDisplacements", "InteractiveDynamics", "InventoryManagement", "IsotopeTableDF", "IterativeLQR", "IterativeRefinement", "JLD2", "JavisNB", "JobSchedulers", "Juice", "JunctionTrees", "Jutul", "JutulDarcy", "Knet", "KnetLayers", "KnetNLPModels", "KomaMRI", "KroneckerTools", "LIBSVM", "LabelledGraphs", "LatticeDiracOperators", "LatticeQCD", "LazyAlgebra", "Leaflet", "Lehmann", "LightOSM", "LinearInterpolators", "MCMCDebugging", "MPIMapReduce", "MPIReco", "MPITestImages", "MRICoilSensitivities", "MRIFiles", "MRIReco", "MRISimulation", "MRIsim", "MagmaThermoKinematics", "ManifestUtilities", "MaterialReconstruction", "MatrixMerge", "MendelImpute", "MetaGraphs", "MetaGraphsNext", "Mitosis", "MolecularGraphKernels", "MonolithicFEMVLFS", "MultiScaleTreeGraph", "MultilayerGraphs", "MultiscaleGraphSignalTransforms", "MutualInformationImageRegistration", "NbodyGradient", "NeidArchive", "NeutronTransport", "NewsLookout", "NighttimeLights", "Nonconvex", "Nullables", "ODEHybrid", "OSMMakie", "OSQP", "OVERT", "Observers", "OceanStateEstimation", "Oceanostics", "PDENLPModels", "POMDPStressTesting", "PSSFSS", "ParameterEstimocean", "Parsers", "PassiveTracerFlows", "Peridynamics", "PharmaceuticalClassification", "Photodynamics", "PlanktonIndividuals", "PlantBiophysics", "PlantGeom", "PlutoStaticHTML", "PointEstimateMethod", "PoreMatMod", "PorousMaterials", "PowerAnalytics", "PowerModelsAnalytics", "PowerSystemsMaps", "ProbabilisticCircuits", "Probably", "PubChemCrawler", "QXContexts", "QXTools", "QXZoo", "RandomMatrices", "RandomMatrixDistributions", "RankRevealing", "RayTracing", "RecoverPose", "RegularizationTools", "Reproduce", "ReusableFunctions", "RiskAdjustedLinearizations", "RoMEPlotting", "RobustPmap", "SMLMData", "SMLMFrameConnection", "SMLMSim", "SUNRepresentations", "Seleroute", "SimpleSolvers", "SmoothingSplines", "SnowyOwl", "SocialSamplingTheory", "SolverBenchmark", "SpecTools", "SpeedyWeather", "SpinGlassNetworks", "SpinGlassPEPS", "StableTrees", "StatisticalGraphics", "TcpInstruments", "TeneT", "TensorBoardLogger", "TensorGames", "TensorKitManifolds", "UnifiedPseudopotentialFormat", "UserConfig", "VisualGeometryDatasets", "WGPUgfx", "WhereTraits", "YaoQX"])

@KristofferC
Copy link
Member

Those are a Pkg bug and not just a branch difference though, right?

My point is that the bug is fixed on master Julia but not on this branch.

@nanosoldier
Copy link
Collaborator

Your job failed. cc @maleadt

@maleadt
Copy link
Member

maleadt commented Nov 18, 2022

@nanosoldier runtests(["AnyMOD", "Casacore", "ClimaTimeSteppers", "CxxWrap", "DickeModel", "FMIFlux", "HomalgProject", "MParT", "Oscar", "Polymake", "QML", "QSimulator", "RangeEnclosures", "SDPA", "Singular", "StaticTools", "TuringGLM", "Z3", "openPMD", "ADI", "AIBECS", "AffineInvariantMCMC", "AlgebraicMultigrid", "ArrayLayouts", "AstroIC", "AstroIO", "AtomGraphs", "AvailablePotentialEnergyFramework", "BIGUQ", "BM3DDenoise", "Baytes", "BetaML", "Bio3DView", "BlobTracking", "BlockDecomposition", "BlockTriangularForm", "Boltz", "BrokenRecord", "CDLmotif", "CSDP", "CairoMakie", "CartesianJoin", "Catlab", "Causal", "CausalInference", "CellSegmentation", "ChainPlots", "ChaoticEncryption", "CineFiles", "CitableImage", "ClimateERA", "ClimateModels", "CollisionDetection", "ColorTypes", "CorrelationFunctions", "CorrelationTrackers", "CumulantsFeatures", "CumulantsUpdates", "DINCAE", "DLMReader", "DSP", "DataAssimilationBenchmarks", "DeconvOptim", "DifferentiableCollisions", "DifferentiableTrajectoryOptimization", "Discord", "Dojo", "DojoEnvironments", "DrelTools", "DrillMudsThermalProps", "EFTfitter", "EasyABM", "EditorsRepo", "EulerCharacteristic", "EvoDynamics", "ExplainableAI", "ExtremeLearning", "FHIRClientXML", "FMI", "FaceDetection", "FastMakie", "FastRunningMedian", "FastVision", "FatDatasets", "FeedbackNets", "FileIO", "FlowAtlas", "FlowWorkspace", "FourierFlows", "FourierGPE", "FunctionTabulations", "GAP", "GCMAES", "GEMPIC", "GMT", "Gaugefields", "GaussianMixtureRegressions", "GaussianMixtures", "GeneralizedSylvesterSolver", "GeophysicalFlows", "GraphDataFrameBridge", "Graphene", "GreenFunc", "GridapGmsh", "HypertextLiteral", "ImageUtils", "ImagineFormat", "InMemoryDatasets", "IndependentComponentAnalysis", "IndividualDisplacements", "InteractiveDynamics", "InventoryManagement", "IsotopeTableDF", "IterativeLQR", "IterativeRefinement", "JLD2", "JavisNB", "JobSchedulers", "Juice", "JunctionTrees", "Jutul", "JutulDarcy", "Knet", "KnetLayers", "KnetNLPModels", "KomaMRI", "KroneckerTools", "LIBSVM", "LabelledGraphs", "LatticeDiracOperators", "LatticeQCD", "LazyAlgebra", "Leaflet", "Lehmann", "LightOSM", "LinearInterpolators", "MCMCDebugging", "MPIMapReduce", "MPIReco", "MPITestImages", "MRICoilSensitivities", "MRIFiles", "MRIReco", "MRISimulation", "MRIsim", "MagmaThermoKinematics", "ManifestUtilities", "MaterialReconstruction", "MatrixMerge", "MendelImpute", "MetaGraphs", "MetaGraphsNext", "Mitosis", "MolecularGraphKernels", "MonolithicFEMVLFS", "MultiScaleTreeGraph", "MultilayerGraphs", "MultiscaleGraphSignalTransforms", "MutualInformationImageRegistration", "NbodyGradient", "NeidArchive", "NeutronTransport", "NewsLookout", "NighttimeLights", "Nonconvex", "Nullables", "ODEHybrid", "OSMMakie", "OSQP", "OVERT", "Observers", "OceanStateEstimation", "Oceanostics", "PDENLPModels", "POMDPStressTesting", "PSSFSS", "ParameterEstimocean", "Parsers", "PassiveTracerFlows", "Peridynamics", "PharmaceuticalClassification", "Photodynamics", "PlanktonIndividuals", "PlantBiophysics", "PlantGeom", "PlutoStaticHTML", "PointEstimateMethod", "PoreMatMod", "PorousMaterials", "PowerAnalytics", "PowerModelsAnalytics", "PowerSystemsMaps", "ProbabilisticCircuits", "Probably", "PubChemCrawler", "QXContexts", "QXTools", "QXZoo", "RandomMatrices", "RandomMatrixDistributions", "RankRevealing", "RayTracing", "RecoverPose", "RegularizationTools", "Reproduce", "ReusableFunctions", "RiskAdjustedLinearizations", "RoMEPlotting", "RobustPmap", "SMLMData", "SMLMFrameConnection", "SMLMSim", "SUNRepresentations", "Seleroute", "SimpleSolvers", "SmoothingSplines", "SnowyOwl", "SocialSamplingTheory", "SolverBenchmark", "SpecTools", "SpeedyWeather", "SpinGlassNetworks", "SpinGlassPEPS", "StableTrees", "StatisticalGraphics", "TcpInstruments", "TeneT", "TensorBoardLogger", "TensorGames", "TensorKitManifolds", "UnifiedPseudopotentialFormat", "UserConfig", "VisualGeometryDatasets", "WGPUgfx", "WhereTraits", "YaoQX"])

@nanosoldier
Copy link
Collaborator

Your package evaluation job has completed - possible new issues were detected. A full report can be found here.

@apaz-cli
Copy link
Member Author

PackageEval reveals that there are many packages with tests relying on parsing MethodError.
ColorTypes, FileIO, HypertextLiteral, and SparseArrays. I already submitted a PR to fix SparseArrays. I'm willing to submit more for the others if you think that's a good idea.

apaz-cli added a commit to apaz-cli/FileIO.jl that referenced this pull request Nov 23, 2022
Apply these changes if JuliaLang/julia#47369
gets merged.

The error message for MethodError currently applies to both calls to
functions and `invoke()`, but did not specify which the error came from.
Fixing this will break some tests, hence this PR.
apaz-cli added a commit to apaz-cli/ColorTypes.jl that referenced this pull request Nov 23, 2022
Apply these changes if JuliaLang/julia#47369
gets merged.

The error message for MethodError currently applies to both calls to
functions and `invoke()`, but did not specify which the error came from.
Fixing this will break some tests, hence this PR.
apaz-cli added a commit to apaz-cli/HypertextLiteral.jl that referenced this pull request Nov 23, 2022
Apply these changes if JuliaLang/julia#47369
gets merged.

The error message for MethodError currently applies to both calls to
functions and `invoke()`, but did not specify which the error came from.
Fixing this will break some tests, hence this PR.
apaz-cli added a commit to apaz-cli/HypertextLiteral.jl that referenced this pull request Nov 23, 2022
Apply these changes if JuliaLang/julia#47369
gets merged.

The error message for MethodError currently applies to both calls to
functions and `invoke()`, but did not specify which the error came from.
Fixing this will break some tests, hence this PR.
apaz-cli added a commit to apaz-cli/FileIO.jl that referenced this pull request Nov 23, 2022
Apply these changes if JuliaLang/julia#47369
gets merged.

The error message for MethodError currently applies to both calls to
functions and `invoke()`, but did not specify which the error came from.
Fixing this will break some tests, hence this PR.
vtjnash added a commit to JuliaSparse/SparseArrays.jl that referenced this pull request Feb 8, 2023
The text of the MethodError message is not a stable API, so use the
currently stable API of checking the field value. Discussion at
JuliaLang/julia#47369.

Co-authored-by: Jameson Nash <[email protected]>
@ViralBShah
Copy link
Member

Do we want to update this and get it merged?

@StefanKarpinski StefanKarpinski added the triage This should be discussed on a triage call label Jan 10, 2024
@vtjnash
Copy link
Member

vtjnash commented Jan 29, 2024

@ViralBShah yes, pushed an update with removing some changes and adding others. Just waiting for final review (of the exact text, not the implementation), if you want to look at it?

@vtjnash vtjnash added merge me PR is reviewed. Merge when all tests are passing and removed triage This should be discussed on a triage call labels Feb 1, 2024
The `MethodError` printing has detailed text on what failed about this
dispatch, which can be useful to someone trying to understand why
`which` failed, given that `which` is simply a model of the dispatch
done by `invoke`. Reuse that printing, but add a short custom header to
it and convert to an ErrorException, per triage discussion that this
would be clearest. Also add more text to `MethodError` to guide new
users in interpreting the exact meaning of some of the cryptic text.

Fixes JuliaLang#47322
@inkydragon
Copy link
Member

CI: tests passed, ASAN timeout is unrelated.

@vtjnash vtjnash merged commit fc06291 into JuliaLang:master Feb 3, 2024
5 of 7 checks passed
@inkydragon inkydragon removed the merge me PR is reviewed. Merge when all tests are passing label Feb 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
error messages Better, more actionable error messages
Projects
None yet
Development

Successfully merging this pull request may close these issues.

which should give better error on ambiguous method
10 participants